G.4 Get the keys of the current level in the menu

@param array $menuData
@return array
773721
private function getArrayKey(array $menuData): array
    {
        $arrayKey = array_keys($menuData);
        $arrayKey = array_diff($arrayKey, $this->remove);
        $arrayKey = array_values($arrayKey);
        return $arrayKey;
    }
35419
private function getErrorParameters(array $entryData)
    {
        $expectedParameterNames = $this->getExpectedParameterNames($entryData[self::KEY_RAW]);
        $parameters = [];
        foreach ($expectedParameterNames as $expectedParameterName) {
            if (isset($entryData[$expectedParameterName])) {
                $parameters[$expectedParameterName] = $entryData[$expectedParameterName];
            } else {
                $parameter = $this->getDerivedParameter($entryData);

                if (is_null($parameter)) {
                    throw new ParserException('Missing expected parameter "'.$expectedParameterName.'"', 2);
                }

                $parameters[$expectedParameterName] = $parameter;
            }
        }

        return $parameters;
    }
1171588
protected function _getCurrentMenuElement(array $options = [], $level = 1)
    {
        if ($level > 1) {
            $levelElement = $this->_getLevelElement($options, $level);
            if ($this->_View->elementExists($levelElement)) {
                return $levelElement;
            }

            return $options['childMenuAttr']['element'];
        }

        return $options['menuAttr']['element'];
    }
1041503
private function _getSecondaryKeys($data, $key = null)
    {
        if ($key) {
            $data = ArrayHelper::getValue($data, $key, []);
        }

        return ArrayHelper::getColumn($data, $this->relSecondaryKey);
    }
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;
    }
1374790
protected function mapIconDataResult(array $iconData): array
    {
        $result = [];
        foreach ($iconData as $data) {
            $result[] = IconData::createFromArray($data);
        }
        return $result;
    }
154025
static function getMenu($users = [])
    {
        $menuTables = self::getAll();
        if ($users && $users['gid'] !== '99') {
            $roleAuths = CommonRoleModel::getInfo($users['gid']);
            $auths = isset($roleAuths['auths']) ? $roleAuths['auths'] : array();
            foreach ($menuTables as $key => $value) {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if(isset($val['items']) && $val['items']) {
                            foreach ($val['items'] as $ks => $v) {
                                if (isset($v['url']) && !in_array($ks, (array) $auths))  {   
                                    unset($menuTables[$key]['items'][$k]['items'][$ks]);
                                } 
                            }
                        }  else if (isset($val['url']) && !in_array($k, (array) $auths)) {   
                            unset($menuTables[$key]['items'][$k]);
                        } 
                    }
                } else {
                    unset($menuTables[$key]);
                }
            }
        }
        foreach ($menuTables as $key => $value) {
            if (isset($value['items']) && empty($value['items'])) {
                unset($menuTables[$key]);
            } else if (isset($value['items']) && !$value['items']) {
                unset($menuTables[$key]);
            } else {
                if(isset($value['items']) && $value['items']) {
                    foreach ($value['items'] as $k => $val) {
                        if (isset($val['items']) && empty($val['items'])) {
                            unset($menuTables[$key]['items'][$k]);
                        } else if ((!isset($val['items']) || !$val['items']) && !isset($val['url'])) {
                            unset($menuTables[$key]['items'][$k]);
                        }
                    }
                }   
            }
        }
        foreach ($menuTables as $key => $value) {
            if ((isset($value['items']) && empty($value['items'])) || (!isset($value['items']) || !$value['items'])) {
                unset($menuTables[$key]);
            }
        }
        return $menuTables;
    }
1148801
public function get_sub_menu_items( $menu_items, $parent_id ) {
		$items = [];

		foreach ( $menu_items as $menu_item ) {
			if ( intval( $parent_id ) === intval( $menu_item->menu_item_parent ) ) {
				$items[] = [
					'title' => $menu_item->title,
					'link' => str_replace( site_url(), '', $menu_item->url ),
					'items' => self::get_sub_menu_items( $menu_items, $menu_item->ID ),
				];
			}
		}

		return $items;
	}
433775
public static function getMenuLinks($menuSlug)
    {
        // Set active MenuLinks
        MenuLink::setActiveIDs(true);

        $menuData = self::findBySlug($menuSlug);
        $menuLinks = MenuLink::where('menuID', $menuData->menuID)->orderBy('order')->get();

        if($menuLinks) {
            return MenuLink::children($menuLinks);
        }
    }
965880
protected function mapTranslationDataResult(array $translationData): array
    {
        $result = [];
        foreach ($translationData as $data) {
            $result[] = TranslationData::createFromArray($data);
        }
        return $result;
    }
481704
public function getMenuItems($menu) {
		if( !isset(self::$menusConf) ) {
			self::$menusConf = IniConfig::build('menus', true);
		}
		if( empty(self::$menusConf) || empty(self::$menusConf->$menu) ) {
			return array();
		}
		return self::$menusConf->$menu;
	}
1160805
public function getChildren()
    {
        if (is_null($this->children)) {
            $this->children = $this->menu->getChildren($this);
        }

        return $this->children;
    }
303067
public function getAfterSaveRoute($data) {
        if ($currentItem = $this->menu->getCurrent()) {
            $controller = $this->_getParam('controller');
            $url        = null;

            if ($data instanceof \Zend_Controller_Request_Abstract) {
                $refData = $data;
            } elseif (is_array($data)) {
                $refData = $this->getModel()->getKeyRef($data) + $data;
            } else {
                throw new \Gems_Exception_Coding('The variable $data must be an array or a ' . 'Zend_Controller_Request_Abstract object.');
            }

            if ($parentItem = $currentItem->getParent()) {
                if ($parentItem instanceof \Gems_Menu_SubMenuItem) {
                    $controller = $parentItem->get('controller');
                }
            }

            // Look for allowed show
            if ($menuItem = $this->menu->find(array('controller' => $controller, 'action' => 'show', 'allowed' => true))) {
                $url = $menuItem->toRouteUrl($refData);
            }

            if (null === $url) {
                // Look for allowed index
                if ($menuItem = $this->menu->find(array('controller' => $controller, 'action' => 'index', 'allowed' => true))) {
                    $url = $menuItem->toRouteUrl($refData);
                }
            }

            if ((null === $url) && ($parentItem instanceof \Gems_Menu_SubMenuItem)) {
                // Still nothing? Try parent item.
                $url = $parentItem->toRouteUrl($refData);
            }

            if (null !== $url) {
                return $url;
            }
        }
        return false;
    }
828623
protected function normalizeMenuPresence($data)
    {
        if ( ! $data) {
            return false;
        }

        if ($data instanceof MenuPresenceInterface) {

            $data = [ $data ];

        } elseif (is_array($data) && ! Arr::isAssoc($data)) {

            $presences = [];

            foreach ($data as $nestedData) {

                if (is_array($nestedData)) {
                    $nestedData = new MenuPresence($nestedData);
                }

                if ( ! ($nestedData instanceof MenuPresenceInterface)) {
                    throw new UnexpectedValueException(
                        'Menu presence data from array provided by module is not an array or menu presence instance'
                    );
                }

                $presences[] = $nestedData;
            }

            $data = $presences;

        } else {

            $data = [ new MenuPresence($data) ];
        }

        /** @var MenuPresenceInterface[] $data */

        // Now normalized to an array with one or more menu presences.
        // Make sure the children of each menu presence are normalized aswell.
        foreach ($data as $index => $presence) {

            $children = $presence->children();

            if ( ! empty($children)) {
                $data[$index]->setChildren(
                    $this->normalizeMenuPresence($children)
                );
            }
        }

        return $data;
    }
590303
public function children($depth = false)
    {
        return $this->menu->whereParentId($this->id, $depth)->all();
    }
158274
public function menus()
    {
        $menus = $this->app->make('menus.collection')->all();

        $headers = ['Slug', 'Top level items', 'Active'];

        $dataset = array_map(function ($menu) {
            return [
                $menu->getSlug(),
                count($menu->items()),
                $menu->isActive() ? 'true' : 'false',
            ];
        }, $menus);

        $this->table($headers, $dataset);
    }
1315339
public function showAction(MenuItem $menuItem)
    {
        $em = $this->getDoctrine()->getManager();
        $deleteForm = $this->createDeleteForm($menuItem);
//        $menuItem = $em->getRepository('CoreExtraBundle:MenuItem')->getItemsWithTranslations($menuItem);
        
        return array(
            'entity' => $menuItem,
            'delete_form' => $deleteForm->createView(),
        );
    }