Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BackendTemplate.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Email\Model;
7 
9 
19 {
23  private $structure;
24 
45  public function __construct(
46  \Magento\Framework\Model\Context $context,
47  \Magento\Framework\View\DesignInterface $design,
48  \Magento\Framework\Registry $registry,
49  \Magento\Store\Model\App\Emulation $appEmulation,
51  \Magento\Framework\View\Asset\Repository $assetRepo,
52  \Magento\Framework\Filesystem $filesystem,
53  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
54  \Magento\Email\Model\Template\Config $emailConfig,
55  \Magento\Email\Model\TemplateFactory $templateFactory,
56  \Magento\Framework\Filter\FilterManager $filterManager,
57  \Magento\Framework\UrlInterface $urlModel,
58  \Magento\Email\Model\Template\FilterFactory $filterFactory,
59  \Magento\Config\Model\Config\Structure $structure,
60  array $data = [],
61  \Magento\Framework\Serialize\Serializer\Json $serializer = null
62  ) {
63  $this->structure = $structure;
64  parent::__construct(
65  $context,
66  $design,
67  $registry,
70  $assetRepo,
76  $urlModel,
77  $filterFactory,
78  $data,
80  );
81  }
82 
89  {
90  $templateId = $this->getId();
91  if (!$templateId) {
92  return [];
93  }
94 
95  $templatePaths = $this->structure->getFieldPathsByAttribute(
96  'source_model',
97  \Magento\Config\Model\Config\Source\Email\Template::class
98  );
99 
100  if (!count($templatePaths)) {
101  return [];
102  }
103 
104  $configData = $this->_getResource()->getSystemConfigByPathsAndTemplateId($templatePaths, $templateId);
105  foreach ($templatePaths as $path) {
106  if ($this->scopeConfig->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT) == $templateId) {
107  foreach ($configData as $data) {
108  if ($data['path'] == $path) {
109  continue 2; // don't add final fallback value if it was found in stored config
110  }
111  }
112 
113  $configData[] = [
115  'path' => $path
116  ];
117  }
118  }
119 
120  return $configData;
121  }
122 }
$templateId
Definition: queue.php:15
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Email\Model\Template\Config $emailConfig, \Magento\Email\Model\TemplateFactory $templateFactory, \Magento\Framework\Filter\FilterManager $filterManager, \Magento\Framework\UrlInterface $urlModel, \Magento\Email\Model\Template\FilterFactory $filterFactory, \Magento\Config\Model\Config\Structure $structure, array $data=[], \Magento\Framework\Serialize\Serializer\Json $serializer=null)