Iterates trough an array and searches the needed menu entry.
If found, return the menu entry, otherwise return false.

@access protected
@param array $menuEntries
@return false|\Zepi\Web\General\Entity\MenuEntry
483136
protected function searchCorrectMenuEntryInArray($menuEntries)
    {
        foreach ($menuEntries as $key => $menuEntry) {
            if (trim($menuEntry->getTarget(), '/') === trim($this->framework->getRequest()->getRoute(), '/')) {
                return $menuEntry;
            }
            
            if ($menuEntry->hasChildren()) {
                $menuEntry = $this->searchCorrectMenuEntryInArray($menuEntry->getChildren());
                
                if ($menuEntry !== false) {
                    return $menuEntry;
                }
            }
        }
        
        return false;
    }
109031
private function orderedEntry(array $entry, array $headerKeys)
    {
        $result = [];

        foreach ($headerKeys as $key) {
            $result[$key] = $entry[$key];
        }

        return $result;
    }
846228
private function fillGroupedMenus(MenuEntry $contentRoot)
    {
        $groups = $this->contentTypes->call(function ($a) {
            $arr = [];
            foreach ($a as $k => $v) {
                if ($v['show_in_menu'] === true) {
                    continue;
                }
                $group = $v['show_in_menu'] ? strtolower($v['show_in_menu']) : 'other';
                $arr[$group][$k] = $v;
            }

            return $arr;
        });
        if ($groups->isEmpty()) {
            return;
        }

        foreach ($groups as $key => $groupContentTypes) {
            $this->addGroupedContentTypes($contentRoot->get($key), $groupContentTypes);
        }
    }
1310934
public function getAccountEntries()
    {
        $entries = [];
        foreach ($this->extensions as $name => $extension) {
            if (null !== $e = $extension->getAccountMenuEntries()) {
                $entries = array_merge($entries, $e);
            }
        }
        return $entries;
    }
1157912
public function add(MenuEntry $menu)
    {
        $menu->parent = $this;
        $menu->urlGenerator = $this->urlGenerator;
        $this->children[$menu->getName()] = $menu;

        return $menu;
    }
1215775
public function removeEntry(MenuEntry $toRemove) {

		foreach($this->entries as $k => $e) {

			if($e === $toRemove) {

				array_splice($this->entries, $k, 1);

				if($toRemove instanceof DynamicMenuEntry) {

					$ndx = array_search($toRemove, $this->dynamicEntries, TRUE);

					if($ndx !== FALSE) {
						array_splice($this->dynamicEntries, $ndx, 1);
					}

				}

				$toRemove = NULL;
				break;
			}
		}
		
		return $this;

	}
219090
public function several(array $ids)
    {
        $results = [];
        foreach ($this->getEntry($ids) as $cacheId=>$entry) {
            if (!$this->isExpired($entry)) {
                $results[$cacheId] =  $this->getPayload($cacheId, $entry);
            }
        }

        return $results;
    }
1046712
protected function getKeyLookup($keys)
	{
		// First pass, create a lookup of the keys.
		$lookup = array();

		foreach ($keys as $key)
		{
			if ($key instanceof \SimpleXMLElement)
			{
				$kName = (string) $key['Index'];
			}
			else
			{
				$kName = $key->Index;
			}

			if (empty($lookup[$kName]))
			{
				$lookup[$kName] = array();
			}

			$lookup[$kName][] = $key;
		}

		return $lookup;
	}
454466
public function addChild(MenuEntry $child)
    {
        if (isset($this->children[$child->getKey()])) {
            return false;
        }
        
        $this->children[$child->getKey()] = $child;
        
        // Sets this MenuEntry as parent of the child
        $child->setParent($this);
        
        return true;
    }
1318162
public function build(MenuEntry $root)
    {
        // Top level header for ContentTypes
        $contentRoot = $root->add(
            MenuEntry::create('content', '')
                ->setLabel(Trans::__('general.phrase.content'))
                ->setIcon('fa:file-text')
                ->setPermission('dashboard')
        );
        $mainContentRoot = $contentRoot->add(
            MenuEntry::create('main')
                ->setPermission('dashboard')
        );

        foreach ($this->contentTypes as $name => $contentType) {
            if ($contentType->get('show_in_menu') !== true) {
                $this->addGroupedMenu($mainContentRoot, $contentType);
            } else {
                $this->addContentType($mainContentRoot, $name, $contentType);
            }
        }

        $this->fillGroupedMenus($mainContentRoot);

        return $root;
    }
676895
private function menuBuilder(array $menu)
    {
        foreach ($menu as $key => $item) {
            $menu[$key] = $this->menuHelper($item);
            if (isset($item['submenu'])) {
                $menu[$key]['submenu'] = $this->menuBuilder($item['submenu']);
            }
        }

        return $menu;
    }
36111
private static function importRecurse($entry, $depth) {
        if ( isset($entry->menu) ) $entry = $entry->menu; // Skip right past these
        if ( ! is_array($entry) ) {
            $link = $entry->link;
            $href = $entry->href;
            if ( is_string($href) ) {
                return new \Tsugi\UI\MenuEntry($link, $href);
            }
            $submenu = self::importRecurse($href, $depth+1);
            return new \Tsugi\UI\MenuEntry($link, $submenu);
        }

        $submenu = new \Tsugi\UI\Menu();
        foreach($entry as $child) {
            $submenu->add(self::importRecurse($child, $depth+1));
        }
        return $submenu;
    }
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;
    }
816628
public function getMatchingEntries()
    {
        if ($this->matchingEntries === null) {
            $this->matchingEntries = array();
            foreach ($this->entries as $entry) {
                $this->matchingEntries = array_merge($this->matchingEntries, $entry->getMatchingEntries());
            }
        }

        return $this->matchingEntries;
    }
1228397
protected function verifyEntries($entries, WebRequest $request)
    {
        foreach ($entries as $key => $entry) {
            // If the entry is a ProtectedMenuEntry, verify the entry
            if ($entry instanceof \Zepi\Web\General\Entity\ProtectedMenuEntry) {
                $result = $this->verifyProtectedEntry($entry, $request);
        
                // If the entry isn't allowed remove it from the array
                if (!$result) {
                    unset($entries[$key]);
                }
            }
        
            // If the entry has children, verify all children
            if ($entry->hasChildren()) {
                $children = $this->verifyEntries($entry->getChildren(), $request);
        
                $entry->setChildren($children);
            }
        }
        
        return $entries;
    }
1159421
public function activateMenuEntry($key = '')
    {
        if ($key != '') {
            $menuEntry = $this->menuManager->getMenuEntryForKey($key);
            
            if ($menuEntry !== false) {
                $this->menuManager->setActiveMenuEntry($menuEntry);
            }
        } else {
            $this->menuManager->activateCorrectMenuEntry();
        }
        
        return $this->menuManager->getActiveMenuEntry();
    }
1026570
public function searchOne(array $criterias = array())
    {
        $results = $this->search($criterias, 1);

        if (count($results) !== 1) {
            return null;
        }

        return $results[0];
    }