Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Variable.php
Go to the documentation of this file.
1 <?php
7 
9 
13 abstract class Variable extends Action
14 {
20  const ADMIN_RESOURCE = 'Magento_Variable::variable';
21 
27  protected $_coreRegistry;
28 
33 
37  protected $resultPageFactory;
38 
42  protected $resultJsonFactory;
43 
47  protected $layoutFactory;
48 
57  public function __construct(
58  \Magento\Backend\App\Action\Context $context,
59  \Magento\Framework\Registry $coreRegistry,
60  \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
61  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
62  \Magento\Framework\View\Result\PageFactory $resultPageFactory,
63  \Magento\Framework\View\LayoutFactory $layoutFactory
64  ) {
65  $this->_coreRegistry = $coreRegistry;
66  parent::__construct($context);
67  $this->resultForwardFactory = $resultForwardFactory;
68  $this->resultJsonFactory = $resultJsonFactory;
69  $this->resultPageFactory = $resultPageFactory;
70  $this->layoutFactory = $layoutFactory;
71  }
72 
78  protected function createPage()
79  {
81  $resultPage = $this->resultPageFactory->create();
82  $resultPage->setActiveMenu('Magento_Variable::system_variable')
83  ->addBreadcrumb(__('Custom Variables'), __('Custom Variables'));
84  return $resultPage;
85  }
86 
92  protected function _initVariable()
93  {
94  $variableId = $this->getRequest()->getParam('variable_id', null);
95  $storeId = (int)$this->getRequest()->getParam('store', 0);
96  /* @var $variable \Magento\Variable\Model\Variable */
97  $variable = $this->_objectManager->create(\Magento\Variable\Model\Variable::class);
98  if ($variableId) {
99  $variable->setStoreId($storeId)->load($variableId);
100  }
101  $this->_coreRegistry->register('current_variable', $variable);
102  return $variable;
103  }
104 }
__()
Definition: __.php:13
$variable
Definition: variable.php:7
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Framework\View\LayoutFactory $layoutFactory)
Definition: Variable.php:57