123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Variable\Controller\Adminhtml\System;
- use Magento\Backend\App\Action;
- /**
- * Custom Variables admin controller
- */
- abstract class Variable extends Action
- {
- /**
- * Authorization level of a basic admin session
- *
- * @see _isAllowed()
- */
- const ADMIN_RESOURCE = 'Magento_Variable::variable';
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_coreRegistry;
- /**
- * @var \Magento\Backend\Model\View\Result\ForwardFactory
- */
- protected $resultForwardFactory;
- /**
- * @var \Magento\Framework\View\Result\PageFactory
- */
- protected $resultPageFactory;
- /**
- * @var \Magento\Framework\Controller\Result\JsonFactory
- */
- protected $resultJsonFactory;
- /**
- * @var \Magento\Framework\View\LayoutFactory
- */
- protected $layoutFactory;
- /**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\Registry $coreRegistry
- * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
- * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
- * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
- * @param \Magento\Framework\View\LayoutFactory $layoutFactory
- */
- public function __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
- ) {
- $this->_coreRegistry = $coreRegistry;
- parent::__construct($context);
- $this->resultForwardFactory = $resultForwardFactory;
- $this->resultJsonFactory = $resultJsonFactory;
- $this->resultPageFactory = $resultPageFactory;
- $this->layoutFactory = $layoutFactory;
- }
- /**
- * Initialize Layout and set breadcrumbs
- *
- * @return \Magento\Backend\Model\View\Result\Page
- */
- protected function createPage()
- {
- /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
- $resultPage = $this->resultPageFactory->create();
- $resultPage->setActiveMenu('Magento_Variable::system_variable')
- ->addBreadcrumb(__('Custom Variables'), __('Custom Variables'));
- return $resultPage;
- }
- /**
- * Initialize Variable object
- *
- * @return \Magento\Variable\Model\Variable
- */
- protected function _initVariable()
- {
- $variableId = $this->getRequest()->getParam('variable_id', null);
- $storeId = (int)$this->getRequest()->getParam('store', 0);
- /* @var $variable \Magento\Variable\Model\Variable */
- $variable = $this->_objectManager->create(\Magento\Variable\Model\Variable::class);
- if ($variableId) {
- $variable->setStoreId($storeId)->load($variableId);
- }
- $this->_coreRegistry->register('current_variable', $variable);
- return $variable;
- }
- }
|