92 parent::__construct($context);
93 $this->_authorization = $context->getAuthorization();
94 $this->_auth = $context->getAuth();
95 $this->_helper = $context->getHelper();
96 $this->_backendUrl = $context->getBackendUrl();
97 $this->_formKeyValidator = $context->getFormKeyValidator();
98 $this->_localeResolver = $context->getLocaleResolver();
99 $this->_canUseBaseUrl = $context->getCanUseBaseUrl();
100 $this->_session = $context->getSession();
108 return $this->_authorization->isAllowed(static::ADMIN_RESOURCE);
135 protected function _setActiveMenu($itemId)
138 $menuBlock = $this->_view->getLayout()->getBlock(
'menu');
139 $menuBlock->setActive($itemId);
140 $parents = $menuBlock->getMenuModel()->getParentItems($itemId);
141 foreach ($parents as
$item) {
143 $this->_view->getPage()->getConfig()->getTitle()->prepend(
$item->getTitle());
156 $this->_view->getLayout()->getBlock(
'breadcrumbs')->addLink(
$label,
$title,
$link);
166 return $this->_moveBlockToContainer(
$block,
'content');
175 return $this->_moveBlockToContainer(
$block,
'left');
184 return $this->_moveBlockToContainer(
$block,
'js');
196 private function _moveBlockToContainer(\
Magento\Framework\View\Element\AbstractBlock
$block, $containerName)
198 $this->_view->getLayout()->setChild($containerName,
$block->getNameInLayout(),
'');
209 $this->_response->setStatusHeader(403,
'1.1',
'Forbidden');
210 if (!$this->_auth->isLoggedIn()) {
213 $this->_view->loadLayout([
'default',
'adminhtml_denied'],
true,
true,
false);
214 $this->_view->renderLayout();
215 $this->_request->setDispatched(
true);
221 $this->_actionFlag->set(
'', self::FLAG_IS_URLS_CHECKED,
true);
227 if ($this->_auth->isLoggedIn()) {
228 $this->_auth->getAuthStorage()->isFirstPageAfterLogin();
241 return !$this->_actionFlag->get(
'', self::FLAG_IS_URLS_CHECKED)
257 $_isValidFormKey =
true;
258 $_isValidSecretKey =
true;
260 if ($this->_auth->isLoggedIn()) {
262 $_isValidFormKey = $this->_formKeyValidator->validate($this->
getRequest());
263 $_keyErrorMsg =
__(
'Invalid Form Key. Please refresh the page.');
264 }
elseif ($this->_backendUrl->useSecretKey()) {
266 $_keyErrorMsg =
__(
'You entered an invalid Secret Key. Please refresh the page.');
269 if (!$_isValidFormKey || !$_isValidSecretKey) {
270 $this->_actionFlag->set(
'', self::FLAG_NO_DISPATCH,
true);
271 $this->_actionFlag->set(
'', self::FLAG_NO_POST_DISPATCH,
true);
272 if ($this->
getRequest()->getQuery(
'isAjax',
false) || $this->
getRequest()->getQuery(
'ajax',
false)) {
274 $this->_objectManager->get(
275 \
Magento\Framework\Json\Helper\Data::class
277 [
'error' =>
true,
'message' => $_keyErrorMsg]
281 $this->
_redirect($this->_backendUrl->getStartupPageUrl());
296 $forceLocale = $this->
getRequest()->getParam(
'locale',
null);
297 if ($this->_objectManager->get(\
Magento\Framework\
Validator\Locale::class)->isValid($forceLocale)) {
298 $this->
_getSession()->setSessionLocale($forceLocale);
302 $this->
_getSession()->setLocale($this->_localeResolver->getLocale());
318 $this->
_getSession()->setIsUrlNotice($this->_actionFlag->get(
'', self::FLAG_IS_URLS_CHECKED));
335 $this->
_getSession()->setIsUrlNotice($this->_actionFlag->get(
'', self::FLAG_IS_URLS_CHECKED));
348 return $this->_helper->getUrl($route,
$params);
358 if (is_array($this->_publicActions) && in_array($this->
getRequest()->getActionName(), $this->_publicActions)) {
362 $secretKey = $this->
getRequest()->getParam(\
Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME,
null);
363 if (!$secretKey || $secretKey != $this->_backendUrl->getSecretKey()) {
elseif(isset( $params[ 'redirect_parent']))
_redirect($path, $arguments=[])
_addJs(\Magento\Framework\View\Element\AbstractBlock $block)
getUrl($route='', $params=[])
const FLAG_IS_URLS_CHECKED
__construct(Action\Context $context)
_addContent(\Magento\Framework\View\Element\AbstractBlock $block)
_addBreadcrumb($label, $title, $link=null)
_forward($action, $controller=null, $module=null, array $params=null)
dispatch(\Magento\Framework\App\RequestInterface $request)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
_addLeft(\Magento\Framework\View\Element\AbstractBlock $block)