Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Template.php
Go to the documentation of this file.
1 <?php
7 
13 {
17  private $_coreRegistry;
18 
22  private $_emailConfig;
23 
27  protected $_templatesFactory;
28 
35  public function __construct(
36  \Magento\Framework\Registry $coreRegistry,
37  \Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory,
38  \Magento\Email\Model\Template\Config $emailConfig,
39  array $data = []
40  ) {
41  parent::__construct($data);
42  $this->_coreRegistry = $coreRegistry;
43  $this->_templatesFactory = $templatesFactory;
44  $this->_emailConfig = $emailConfig;
45  }
46 
52  public function toOptionArray()
53  {
55  if (!($collection = $this->_coreRegistry->registry('config_system_email_template'))) {
56  $collection = $this->_templatesFactory->create();
57  $collection->load();
58  $this->_coreRegistry->register('config_system_email_template', $collection);
59  }
60  $options = $collection->toOptionArray();
61  $templateId = str_replace('/', '_', $this->getPath());
62  $templateLabel = $this->_emailConfig->getTemplateLabel($templateId);
63  $templateLabel = __('%1 (Default)', $templateLabel);
64  array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]);
65  return $options;
66  }
67 }
__()
Definition: __.php:13
$templateId
Definition: queue.php:15
__construct(\Magento\Framework\Registry $coreRegistry, \Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory, \Magento\Email\Model\Template\Config $emailConfig, array $data=[])
Definition: Template.php:35