Template.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Email\Controller\Adminhtml\Email;
  7. /**
  8. * System Template admin controller
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. abstract class Template extends \Magento\Backend\App\Action
  13. {
  14. /**
  15. * Authorization level of a basic admin session
  16. *
  17. * @see _isAllowed()
  18. */
  19. const ADMIN_RESOURCE = 'Magento_Email::template';
  20. /**
  21. * Core registry
  22. *
  23. * @var \Magento\Framework\Registry
  24. * @deprecated 101.0.0 since 2.3.0 in favor of stateful global objects elimination.
  25. */
  26. protected $_coreRegistry = null;
  27. /**
  28. * @param \Magento\Backend\App\Action\Context $context
  29. * @param \Magento\Framework\Registry $coreRegistry
  30. */
  31. public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry)
  32. {
  33. $this->_coreRegistry = $coreRegistry;
  34. parent::__construct($context);
  35. }
  36. /**
  37. * Load email template from request
  38. *
  39. * @param string $idFieldName
  40. * @return \Magento\Email\Model\BackendTemplate $model
  41. */
  42. protected function _initTemplate($idFieldName = 'template_id')
  43. {
  44. $id = (int)$this->getRequest()->getParam($idFieldName);
  45. $model = $this->_objectManager->create(\Magento\Email\Model\BackendTemplate::class);
  46. if ($id) {
  47. $model->load($id);
  48. }
  49. return $model;
  50. }
  51. }