@param string $menuItemControllerHandle
@param bool   $pkgHandle
@param array  $options

@return Item
342625
public function addPageHeaderMenuItem(
        $menuItemControllerHandle,
        $pkgHandle = false,
        $options = array()
    ) {
        $defaults = array(
            'icon' => 'share',
            'label' => false,
            'position' => 'right',
            'href' => false,
            'linkAttributes' => array(),
        );

        $options = array_merge($defaults, $options);

        $obj = new Item($menuItemControllerHandle, $pkgHandle);
        $obj->setLabel($options['label']);
        $obj->setPosition($options['position']);
        $obj->setIcon($options['icon']);
        if ($options['href']) {
            $obj->setLink($options['href']);
        }
        $obj->setLinkAttributes($options['linkAttributes']);
        $this->addMenuItem($obj);

        return $obj;
    }
130907
public static function getUrlsByParentId($isSuper, $menuIdList, $parentId, $condition = '', $params = [], $order = 'display_order asc')
    {
        $data = static::find()
            ->normal()
            ->findByParentId($parentId)
            ->andWhere($condition, $params)
            ->active()
            ->orderBy($order)
            ->asArray()
            ->all();
        $urls = [];
        if ($data) {
            foreach ($data as $item) {
                if ($isSuper || in_array($item['menu_id'], $menuIdList)) {
                    $menuUrls = DpAdminMenuUrlRelation::getAllUrlByMenuId($item['menu_id']);
                    if ($menuUrls) {
                        foreach ($menuUrls as $menuUrl) {
                            $urls[$menuUrl['alias']] = Url::toRoute($menuUrl['route']);
                        }
                    }
                    $childrenUrls = static::getUrlsByParentId($isSuper, $menuIdList, $item['menu_id'], $condition, $params, $order);
                    if ($childrenUrls) {
                        $urls = array_merge($urls, $childrenUrls);
                    }
                }
            }
        }

        return $urls;
    }
1131558
function (menuId, menuItemId, menuItemTitle, menuItemUiState, menuItemType, position) {
            this.validateMenuExistance(menuId);

            // Push new menu item
            menus[menuId].items.push({
                id: menuItemId,
                title: menuItemTitle,
                uiState: menuItemUiState,
                class: menuItemType,
                position: position || 0,
                items: []
            });

            // Return the menu object
            return menus[menuId];
        }
574035
public function getParentMenu(Menu $menu, MenuItem $childNode)
    {
        $itemIterator = new RecursiveItemIterator($menu->getIterator());
        $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $menuItem) {
            $parentId = $childNode->getParent()->getId();
            if ($menuItem->getName() != $parentId) {
                continue;
            }

            return $menuItem;
        }

        return false;
    }
1067136
public function subMenu($key = null, $menuItem = null)
    {
        if (null === $menuItem) {
            return $this->subMenu;
        }

        if (is_callable($menuItem)) {
            $menu = new AdminMenu($menuItem);
            $this->subMenu[$key] = $menu;
        } else {
            $this->subMenu[$key] = $menuItem;
        }

        return $this;
    }
732478
public static function createMenuItem(array $item): MenuItemInterface
    {
        $menuItem = static::_getMenuItemObject($item);
        foreach ($item as $key => $value) {
            if ($key == 'children') {
                foreach ($value as $k => $v) {
                    $childItem = static::createMenuItem($v);
                    $menuItem->addMenuItem($childItem);
                }
            } elseif ($key == 'attributes') {
                foreach ($value as $k => $v) {
                    $menuItem->addAttribute($k, $v);
                }
            } elseif ($key == 'viewElement') {
                call_user_func_array([$menuItem, 'setViewElement'], $value);
            } else {
                $method = 'set' . ucfirst(Inflector::camelize($key));
                if (method_exists($menuItem, $method)) {
                    $menuItem->$method($value);
                }
            }
        }

        return $menuItem;
    }
842173
public function getMenu(string $menuClass, $options = []): ItemInterface
    {
        // Merge Options
        $options = array_merge($this->defaultOptions, $options);

        // Get Menu
        $menu = $this->container->has($menuClass) ? $this->container->get($menuClass) : new $menuClass();

        // Render
        if ($menu instanceof MenuInterface) {
            return $this->itemProcess->processMenu($menu->createMenu($options), $options);
        }

        return false;
    }
570833
private function menuSorter(): Closure
    {
        return static function (ModuleMenuInterface $x, ModuleMenuInterface $y): int {
            return $x->getMenuOrder() <=> $y->getMenuOrder();
        };
    }
620432
private void createMenuEntry(
        MenuItem parent,
        final CmsTreeNode<I_CmsContextMenuItem> node,
        CmsContextMenuTreeBuilder treeBuilder) {

        Command entryCommand = null;
        if (node.getChildren().size() == 0) {
            entryCommand = new Command() {

                private static final long serialVersionUID = 1L;

                public void menuSelected(MenuItem selectedItem) {

                    node.getData().executeAction(getDialogContext());
                }
            };
        }
        MenuItem entry = parent.addItem((node.getData().getTitle(A_CmsUI.get().getLocale())), entryCommand);
        for (CmsTreeNode<I_CmsContextMenuItem> child : node.getChildren()) {
            createMenuEntry(entry, child, treeBuilder);
        }
        if (treeBuilder.getVisibility(node.getData()).isInActive()) {
            entry.setEnabled(false);
        }
    }
355634
public function createStructure(array $options): ItemInterface
    {
        /** @var \eZ\Publish\API\Repository\Values\Content\Location $parentLocation */
        $parentLocation = $options['parentLocation'];
        /** @var \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType */
        $contentType = $options['content_type'];
        $parentContentType = $parentLocation->getContent()->getContentType();
        /** @var \eZ\Publish\API\Repository\Values\Content\Language $language */
        $language = $options['language'];
        /** @var \Knp\Menu\ItemInterface|\Knp\Menu\ItemInterface[] $menu */
        $menu = $this->factory->createItem('root');

        $contentCreateStruct = $this->createContentCreateStruct($parentLocation, $contentType, $language);
        $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocation->id);

        $canPublish = $this->permissionResolver->canUser('content', 'publish', $contentCreateStruct, [$locationCreateStruct]);
        $canCreate = $this->permissionResolver->canUser('content', 'create', $contentCreateStruct, [$locationCreateStruct]) && $parentContentType->isContainer;
        $canPreview = $this->permissionResolver->canUser('content', 'versionread', $contentCreateStruct, [$locationCreateStruct]);

        $publishAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_publish',
        ];
        $createAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_saveDraft',
        ];
        $previewAttributes = [
            'class' => self::BTN_TRIGGER_CLASS,
            'data-click' => '#ezrepoforms_content_edit_preview',
        ];

        $menu->setChildren([
            self::ITEM__PUBLISH => $this->createMenuItem(
                self::ITEM__PUBLISH,
                [
                    'attributes' => $canCreate && $canPublish
                        ? $publishAttributes
                        : array_merge($publishAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'publish',
                        'orderNumber' => 10,
                    ],
                ]
            ),
            self::ITEM__SAVE_DRAFT => $this->createMenuItem(
                self::ITEM__SAVE_DRAFT,
                [
                    'attributes' => $canCreate
                        ? $createAttributes
                        : array_merge($createAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'save',
                        'orderNumber' => 50,
                    ],
                ]
            ),
            self::ITEM__PREVIEW => $this->createMenuItem(
                self::ITEM__PREVIEW,
                [
                    'attributes' => $canPreview
                        ? $previewAttributes
                        : array_merge($previewAttributes, self::BTN_DISABLED_ATTR),
                    'extras' => [
                        'icon' => 'view-desktop',
                        'orderNumber' => 60,
                    ],
                ]
            ),
            self::ITEM__CANCEL => $this->createMenuItem(
                self::ITEM__CANCEL,
                [
                    'attributes' => [
                        'class' => self::BTN_TRIGGER_CLASS,
                        'data-click' => '#ezrepoforms_content_edit_cancel',
                    ],
                    'extras' => [
                        'icon' => 'circle-close',
                        'orderNumber' => 70,
                    ],
                ]
            ),
        ]);

        return $menu;
    }
11287
public function &addItem(MenuItem $menu_item)
    {
        $this->items[$menu_item->getName()] = $menu_item;

        return $this->items[$menu_item->getName()];
    }
359974
public function createStructure(array $options): ItemInterface
    {
        /** @var ItemInterface|ItemInterface[] $menu */
        $menu = $this->factory->createItem('root');

        $menu->setChildren([
            self::ITEM__CREATE => $this->createMenuItem(
                self::ITEM__CREATE,
                [
                    'attributes' => [
                        'class' => 'btn--trigger',
                        'data-click' => '#ezrepoforms_user_create_create',
                    ],
                    'extras' => ['icon' => 'publish'],
                ]
            ),
            self::ITEM__CANCEL => $this->createMenuItem(
                self::ITEM__CANCEL,
                [
                    'attributes' => [
                        'class' => 'btn--trigger',
                        'data-click' => '#ezrepoforms_user_create_cancel',
                    ],
                    'extras' => ['icon' => 'circle-close'],
                ]
            ),
        ]);

        return $menu;
    }
471432
public function createFromMenuItem(MenuItem $menuItem)
    {
        if ($path = $menuItem->getPath()) {
            $uri = $this->request->getBaseUrl().$path;
        } elseif ($menuItem->getRedirectUrl()) {
            $uri = $menuItem->getRedirectUrl();
        } elseif ($menuItem->getInternalUrl()) {
            $uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
        } elseif ($contentRoute = $menuItem->getContentRoute()) {
            $route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
            $uri = $this->request->getBaseUrl().$route->getPath();
        } else {
            $uri = '#';
        }

        $options = [
            'uri' => $uri,
            'label' => $menuItem->getName(),
            'attributes' => [],
            'linkAttributes' => $menuItem->getLinkAttributes(),
            'childrenAttributes' => [],
            'labelAttributes' => [],
            'extras' => [],
            'display' => true,
            'displayChildren' => true,

        ];
        $item = $this->factory->createItem($menuItem->getId(), $options);

        if ($menuItem->isHidden()) {
            $item->setDisplay(false);
        }

        return $item;
    }
593151
public function createStructure(array $options): ItemInterface
    {
        /** @var bool $location */
        $canDelete = $this->permissionResolver->hasAccess('content', 'cleantrash');
        /** @var int $trashItemsCount */
        $trashItemsCount = $this->trashService->findTrashItems(new Query())->count;
        /** @var ItemInterface|ItemInterface[] $menu */
        $menu = $this->factory->createItem('root');

        $menu->addChild(
            $this->createMenuItem(self::ITEM__EMPTY, [
                'extras' => ['icon' => 'trash-empty'],
                'attributes' => $canDelete > 0 && $trashItemsCount > 0
                    ? ['data-toggle' => 'modal', 'data-target' => '#confirmEmptyTrash']
                    : ['class' => 'disabled'],
            ])
        );

        return $menu;
    }
673638
public function findBy(string $key, string $value, callable $callback = null): ?MenuItem
    {
        $item = $this->items->filter(function ($item) use ($key, $value) {
            return $item->{$key} === $value;
        })->first();

        (! is_callable($callback) || ! $item) || call_user_func($callback, $item);

        return $item;
    }
35036
public function createPlacementNavigation($rootNode, $admin, $controller, $menuItemManager)
    {
        $lastEdited = $this->get('session')->get('MenuItem.last_edited');

        $nodeDecorator = function ($node) use ($admin, $controller, $menuItemManager, $lastEdited) {
            if ($lastEdited == $node['id']) {
                return;
            }
            $node = $menuItemManager->find($node['id']);

            return $controller->renderView(
                '@NetworkingInitCms/MenuItemAdmin/placement_item.html.twig',
                ['admin' => $admin, 'last_edited' => $lastEdited, 'node' => $node]
            );
        };

        $childOpen = function ($node) use ($lastEdited) {
            if ($lastEdited == $node['id']) {
                return;
            }

            return sprintf(
                '<li class="table-row-style list_item" id="listItem_%s">',
                $node['id']
            );
        };

        $childClose = function ($node) use ($lastEdited, $admin, $controller) {
            if ($lastEdited == $node['id']) {
                return;
            }

            return $controller->renderView(
                '@NetworkingInitCms/MenuItemAdmin/placement_item_end.html.twig',
                ['admin' => $admin, 'last_edited' => $lastEdited, 'node' => $node]
            );
        };

        $rootOpen = function ($tree) {
            $node = $tree[0];
            if ($node['lvl'] == 1) {
                $class = 'ui-sortable';
            } else {
                $class = 'table-row-style';
            }

            return sprintf('<ul class="%s">', $class);
        };

        $navigation = $menuItemManager->childrenHierarchy(
            $rootNode,
            null,
            [
                'rootOpen' => $rootOpen,
                'decorate' => true,
                'childOpen' => $childOpen,
                'childClose' => $childClose,
                'nodeDecorator' => $nodeDecorator,
            ],
            false
        );

        return $navigation;
    }
970473
public static function getClass($pkgHandle)
    {
        if (is_dir(DIR_STARTING_POINT_PACKAGES . '/' . $pkgHandle)) {
            $class = '\\Application\\StartingPointPackage\\' . camelcase($pkgHandle) . '\\Controller';
        } else {
            $class = '\\Concrete\\StartingPointPackage\\' . camelcase($pkgHandle) . '\\Controller';
        }
        if (class_exists($class, true)) {
            $cl = Core::build($class);
        } else {
            $cl = null;
        }

        return $cl;
    }