/** * 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; }
/** * 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; }
public function testGetTemplateLabel() { $this->assertEquals('Template One', $this->model->getTemplateLabel('template_one')); }