Exemple #1
0
 /**
  * Get html code
  *
  * @return string
  */
 protected function _toHtml()
 {
     /* @var $template \Magento\Newsletter\Model\Template */
     $template = $this->_templateFactory->create();
     if ($id = (int) $this->getRequest()->getParam('id')) {
         $template->load($id);
     } else {
         $template->setTemplateType($this->getRequest()->getParam('type'));
         $template->setTemplateText($this->getRequest()->getParam('text'));
         $template->setTemplateStyles($this->getRequest()->getParam('styles'));
     }
     $storeId = (int) $this->getRequest()->getParam('store_id');
     if (!$storeId) {
         $storeId = $this->_storeManager->getDefaultStoreView()->getId();
     }
     \Magento\Framework\Profiler::start("newsletter_template_proccessing");
     $vars = array();
     $vars['subscriber'] = $this->_subscriberFactory->create();
     if ($this->getRequest()->getParam('subscriber')) {
         $vars['subscriber']->load($this->getRequest()->getParam('subscriber'));
     }
     $template->emulateDesign($storeId);
     $templateProcessed = $this->_appState->emulateAreaCode(\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, array($template, 'getProcessedTemplate'), array($vars, true));
     $template->revertDesign();
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     \Magento\Framework\Profiler::stop("newsletter_template_proccessing");
     return $templateProcessed;
 }
Exemple #2
0
 /**
  * Get html code
  *
  * @return string
  */
 protected function _toHtml()
 {
     /* @var $template \Magento\Newsletter\Model\Template */
     $template = $this->_templateFactory->create();
     if ($id = (int) $this->getRequest()->getParam('id')) {
         $this->loadTemplate($template, $id);
     } else {
         $previewData = $this->getPreviewData();
         $template->setTemplateType($previewData['type']);
         $template->setTemplateText($previewData['text']);
         $template->setTemplateStyles($previewData['styles']);
     }
     \Magento\Framework\Profiler::start($this->profilerName);
     $vars = [];
     $vars['subscriber'] = $this->_subscriberFactory->create();
     if ($this->getRequest()->getParam('subscriber')) {
         $vars['subscriber']->load($this->getRequest()->getParam('subscriber'));
     }
     $template->emulateDesign($this->getStoreId());
     $templateProcessed = $this->_appState->emulateAreaCode(\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, [$template, 'getProcessedTemplate'], [$vars]);
     $template->revertDesign();
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     \Magento\Framework\Profiler::stop($this->profilerName);
     return $templateProcessed;
 }
 /**
  * Retrieve included template
  *
  * @param string $templateCode
  * @param array $variables
  * @return string
  */
 public function getInclude($templateCode, array $variables)
 {
     /** @var \Magento\Newsletter\Model\Template $template */
     $template = $this->_templateFactory->create();
     $template->loadByCode($templateCode)->getProcessedTemplate($variables);
     return $template;
 }
Exemple #4
0
 public function testGetTemplate()
 {
     $template = $this->getMockBuilder('\\Magento\\Newsletter\\Model\\Template')->disableOriginalConstructor()->getMock();
     $this->queue->setTemplateId(2);
     $this->templateFactory->expects($this->once())->method('create')->willReturn($template);
     $template->expects($this->once())->method('load')->with(2)->willReturnSelf();
     $this->assertEquals($template, $this->queue->getTemplate());
 }
Exemple #5
0
 /**
  * Retrieve Newsletter Template object
  *
  * @return \Magento\Newsletter\Model\Template
  */
 public function getTemplate()
 {
     if ($this->_template === null) {
         $this->_template = $this->_templateFactory->create()->load($this->getTemplateId());
     }
     return $this->_template;
 }