![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Amasty/MWishlist/Model/Source/Email/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Multiple Wishlist for Magento 2 */ namespace Amasty\MWishlist\Model\Source\Email; use Amasty\MWishlist\Model\ResourceModel\Template\Collection; use Magento\Framework\DataObject; use Magento\Framework\Option\ArrayInterface; class AbstractTemplate extends DataObject implements ArrayInterface { /** * @var \Magento\Email\Model\Template\Config */ private $emailConfig; /** * @var string */ private $origTemplateCode; /** * @var Collection */ private $collection; public function __construct( \Magento\Email\Model\Template\Config $emailConfig, Collection $collection, $origTemplateCode = '', array $data = [] ) { parent::__construct($data); $this->emailConfig = $emailConfig; $this->origTemplateCode = $origTemplateCode; $this->collection = $collection; } /** * @return array */ public function toOptionArray(): array { $this->collection->addFieldToFilter('orig_template_code', ['eq' => $this->origTemplateCode])->load(); $options = $this->collection->toOptionArray(); array_unshift($options, $this->getDefaultTemplate()); return $options; } /** * @return array */ private function getDefaultTemplate(): array { $templateId = str_replace('/', '_', $this->getPath()); $templateLabel = $this->emailConfig->getTemplateLabel($templateId); $templateLabel = __('%1 (Default)', $templateLabel); return ['value' => $templateId, 'label' => $templateLabel]; } }