Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Edit.php
Go to the documentation of this file.
1 <?php
7 
14 use Magento\Framework\View\Result\PageFactory as ResultPageFactory;
16 
20 class Edit extends Action
21 {
25  protected $resultPageFactory;
26 
30  protected $scopeValidator;
31 
35  protected $scopeResolverPool;
36 
43  public function __construct(
44  Context $context,
45  ResultPageFactory $resultPageFactory,
46  ScopeValidator $scopeValidator,
48  ) {
49  $this->resultPageFactory = $resultPageFactory;
50  $this->scopeValidator = $scopeValidator;
51  $this->scopeResolverPool = $scopeResolverPool;
52  parent::__construct($context);
53  }
54 
58  public function execute()
59  {
60  $scope = $this->getRequest()->getParam('scope');
61  $scopeId = $this->getRequest()->getParam('scope_id');
62 
63  if (!$this->scopeValidator->isValidScope($scope, $scopeId)) {
65  $resultRedirect = $this->resultRedirectFactory->create();
66  $resultRedirect->setPath('theme/design_config/');
67  return $resultRedirect;
68  }
69 
71  $resultPage = $this->resultPageFactory->create();
72  $resultPage->setActiveMenu('Magento_Theme::design_config');
73  $resultPage->getConfig()->getTitle()->prepend(__('%1', $this->getScopeTitle()));
74  return $resultPage;
75  }
76 
82  protected function getScopeTitle()
83  {
84  $scope = $this->getRequest()->getParam('scope');
85  $scopeId = $this->getRequest()->getParam('scope_id');
86 
88  $scopeResolver = $this->scopeResolverPool->get($scope);
89  $scopeObject = $scopeResolver->getScope($scopeId);
90  return __('%1', $scopeObject->getName());
91  }
92 
93  return __('Global');
94  }
95 
101  protected function _isAllowed()
102  {
103  return $this->_authorization->isAllowed('Magento_Config::config_design');
104  }
105 }
__()
Definition: __.php:13
__construct(Context $context, ResultPageFactory $resultPageFactory, ScopeValidator $scopeValidator, ScopeResolverPool $scopeResolverPool)
Definition: Edit.php:43