Пример #1
0
 /**
  * Generate list of email templates
  *
  * @return array
  */
 public function toOptionArray()
 {
     /** @var $collection \Magento\Email\Model\Resource\Template\Collection */
     if (!($collection = $this->_coreRegistry->registry('config_system_email_template'))) {
         $collection = $this->_templatesFactory->create();
         $collection->load();
         $this->_coreRegistry->register('config_system_email_template', $collection);
     }
     $options = $collection->toOptionArray();
     $templateId = str_replace('/', '_', $this->getPath());
     $templateLabel = $this->_emailConfig->getTemplateLabel($templateId);
     $templateLabel = __('%1 (Default)', $templateLabel);
     array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]);
     return $options;
 }
Пример #2
0
 /**
  * Get default templates as options array
  *
  * @return array
  */
 protected function _getDefaultTemplatesAsOptionsArray()
 {
     $options = [['value' => '', 'label' => '', 'group' => '']];
     foreach ($this->_emailConfig->getAvailableTemplates() as $templateId) {
         $options[] = ['value' => $templateId, 'label' => $this->_emailConfig->getTemplateLabel($templateId), 'group' => $this->_emailConfig->getTemplateModule($templateId)];
     }
     uasort($options, function (array $firstElement, array $secondElement) {
         return strcmp($firstElement['label'], $secondElement['label']);
     });
     return $options;
 }
Пример #3
0
 public function testGetTemplateLabel()
 {
     $this->assertEquals('Template One', $this->model->getTemplateLabel('template_one'));
 }