Ejemplo n.º 1
0
 /**
  * Prepare html output
  *
  * @return string
  */
 protected function _toHtml()
 {
     /** @var $template \Magento\Email\Model\Template */
     $template = $this->_emailFactory->create(['data' => ['area' => \Magento\Framework\App\Area::AREA_FRONTEND]]);
     $id = (int) $this->getRequest()->getParam('id');
     if ($id) {
         $template->load($id);
     } else {
         $template->setTemplateType($this->getRequest()->getParam('type'));
         $template->setTemplateText($this->getRequest()->getParam('text'));
         $template->setTemplateStyles($this->getRequest()->getParam('styles'));
     }
     $template->setTemplateText($this->_maliciousCode->filter($template->getTemplateText()));
     \Magento\Framework\Profiler::start("email_template_proccessing");
     $vars = [];
     $store = $this->getAnyStoreView();
     $storeId = $store ? $store->getId() : null;
     $template->setDesignConfig(['area' => $this->_design->getArea(), 'store' => $storeId]);
     $templateProcessed = $template->getProcessedTemplate($vars, true);
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     \Magento\Framework\Profiler::stop("email_template_proccessing");
     return $templateProcessed;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getSearchableEntities($storeId, $entityIds = null, $lastEntityId = null, $limit = 100)
 {
     $collection = $this->collectionFactory->create()->addStoreFilter($storeId)->addFieldToFilter('is_active', 1);
     $ignored = $this->getModel()->getProperty('ignored_pages');
     if (is_array($ignored) && count($ignored)) {
         $collection->addFieldToFilter('identifier', ['nin' => $ignored]);
     }
     if ($entityIds) {
         $collection->addFieldToFilter('page_id', $entityIds);
     }
     $collection->addFieldToFilter('page_id', ['gt' => $lastEntityId])->setPageSize($limit)->setOrder('page_id');
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     try {
         /** @var \Magento\Store\Model\App\Emulation $emulation */
         $emulation = $objectManager->create('Magento\\Store\\Model\\App\\Emulation');
         $emulation->startEnvironmentEmulation($storeId, true);
         /** @var \Magento\Cms\Model\Page $page */
         foreach ($collection as $page) {
             $template = $this->emailTemplateFactory->create();
             $template->emulateDesign($storeId);
             $template->setTemplateText($page->getContent())->setIsPlain(false);
             $template->setTemplateFilter($this->cmsFilterProvider->getPageFilter());
             $html = $template->getProcessedTemplate([]);
             $page->setContent($page->getContent() . $html);
         }
         $emulation->stopEnvironmentEmulation();
     } catch (\Exception $e) {
     }
     return $collection;
 }
Ejemplo n.º 3
0
 /**
  * Prepare html output
  *
  * @return string
  */
 protected function _toHtml()
 {
     $storeId = $this->getAnyStoreView()->getId();
     /** @var $template \Magento\Email\Model\Template */
     $template = $this->_emailFactory->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'));
     }
     $template->setTemplateText($this->_maliciousCode->filter($template->getTemplateText()));
     \Magento\Framework\Profiler::start($this->profilerName);
     $template->emulateDesign($storeId);
     $templateProcessed = $this->_appState->emulateAreaCode(\Magento\Email\Model\AbstractTemplate::DEFAULT_DESIGN_AREA, [$template, 'getProcessedTemplate']);
     $template->revertDesign();
     if ($template->isPlain()) {
         $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
     }
     \Magento\Framework\Profiler::stop($this->profilerName);
     return $templateProcessed;
 }
Ejemplo n.º 4
0
 /**
  * Return a new instance of the template object. Used by the template directive.
  *
  * @return \Magento\Email\Model\AbstractTemplate
  */
 protected function getTemplateInstance()
 {
     return $this->templateFactory->create();
 }
Ejemplo n.º 5
0
 /**
  * Return a new instance of the template object. Used by the template directive.
  *
  * @return \Magento\Email\Model\AbstractTemplate
  */
 protected function getTemplateInstance()
 {
     return $this->templateFactory->create(['filesystem' => $this->filesystem]);
 }