Last active
June 10, 2019 17:32
-
-
Save magevision/addd1da9450d29ea441c13169b95d583 to your computer and use it in GitHub Desktop.
GetListOfEmailTemplates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MageVision\Blog46\Helper; | |
use Magento\Framework\App\Helper\AbstractHelper; | |
use Magento\Framework\App\Helper\Context; | |
use Magento\Email\Model\ResourceModel\Template\CollectionFactory; | |
use Magento\Email\Model\Template\Config; | |
class Data extends AbstractHelper | |
{ | |
/** | |
* @var CollectionFactory | |
*/ | |
protected $collectionFactory; | |
/** | |
* @var Config | |
*/ | |
protected $emailTemplateConfig; | |
/** | |
* @param Context $context | |
* @param CollectionFactory $collectionFactory | |
* @param Config $emailTemplateConfig | |
*/ | |
public function __construct( | |
Context $context, | |
CollectionFactory $collectionFactory, | |
Config $emailTemplateConfig | |
) { | |
parent::__construct($context); | |
$this->collectionFactory = $collectionFactory; | |
$this->emailTemplateConfig = $emailTemplateConfig; | |
} | |
/** | |
* Returns collection of all custom templates created in backend | |
* | |
* @return mixed | |
*/ | |
public function getCustomTemplates() | |
{ | |
return $this->collectionFactory->create(); | |
} | |
/** | |
* Return list of all email templates, both default module and theme-specific templates | |
* | |
* @return array[] | |
*/ | |
public function getConfigTemplates() | |
{ | |
return $this->emailTemplateConfig->getAvailableTemplates(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment