150 private $_moduleManager;
171 \
Magento\Framework\AuthorizationInterface $authorization,
173 \
Magento\Backend\Model\MenuFactory $menuFactory,
175 \
Magento\Framework\Module\ModuleListInterface $moduleList,
179 $this->_validator = $validator;
180 $this->_validator->validate(
$data);
182 $this->_acl = $authorization;
183 $this->_scopeConfig = $scopeConfig;
184 $this->_menuFactory = $menuFactory;
185 $this->_urlModel = $urlModel;
186 $this->_moduleList = $moduleList;
198 protected function _getArgument(array $array, $key, $defaultValue =
null)
200 return isset($array[$key]) ? $array[$key] : $defaultValue;
221 return $this->target;
231 return (
null !== $this->_submenu) && (bool)$this->_submenu->count();
241 if (!$this->_submenu) {
242 $this->_submenu = $this->_menuFactory->create();
254 if ((
bool)$this->_action) {
255 return $this->_urlModel->getUrl((
string)$this->_action, [
'_cache_secret_key' =>
true]);
279 $this->_validator->validateParam(
'action', $action);
280 $this->_action = $action;
291 return $this->
getUrl() ==
'#';
301 if ($this->
getUrl() ==
'#') {
302 return 'return false;';
326 $this->_validator->validateParam(
'title',
$title);
360 $this->_validator->validateParam(
'toolTip', $tooltip);
361 $this->_tooltip = $tooltip;
374 $this->_validator->validateParam(
'module', $module);
375 $this->_moduleName = $module;
388 $this->_validator->validateParam(
'dependsOnModule', $moduleName);
389 $this->_dependsOnModule = $moduleName;
402 $this->_validator->validateParam(
'dependsOnConfig', $configPath);
403 $this->_dependsOnConfig = $configPath;
414 return !$this->_moduleManager->isOutputEnabled(
426 if ($this->_dependsOnModule) {
428 return $this->_moduleList->has($module);
440 if ($this->_dependsOnConfig) {
441 return $this->_scopeConfig->isSetFlag((
string)$this->_dependsOnConfig, ScopeInterface::SCOPE_STORE);
454 return $this->_acl->isAllowed((
string)$this->_resource);
455 }
catch (\Exception $e) {
480 'target' => $this->target,
481 'sub_menu' => isset($this->_submenu) ? $this->_submenu->toArray() : null
494 $this->_parentId = $this->
_getArgument($data,
'parent_id');
495 $this->_moduleName = $this->
_getArgument($data,
'module',
'Magento_Backend');
496 $this->_sortIndex = $this->
_getArgument($data,
'sort_index');
497 $this->_dependsOnConfig = $this->
_getArgument($data,
'dependsOnConfig');
499 $this->_resource = $this->
_getArgument($data,
'resource');
502 $this->_dependsOnModule = $this->
_getArgument($data,
'dependsOnModule');
503 $this->_tooltip = $this->
_getArgument($data,
'toolTip');
506 $this->_submenu =
null;
507 if (isset(
$data[
'sub_menu'])) {
508 $menu = $this->_menuFactory->create();
509 $menu->populateFromArray(
$data[
'sub_menu']);
510 $this->_submenu = $menu;