Adds locations from $searchHit to $menu.

@param ItemInterface $menu
@param SearchHit[] $searchHits
558846
private function addLocationsToMenu(ItemInterface $menu, array $searchHits)
    {
        foreach ($searchHits as $searchHit) {
            /** @var Location $location */
            $location = $searchHit->valueObject;
            $menuItem = isset($menu[$location->parentLocationId]) ? $menu[$location->parentLocationId] : $menu;
            $menuItem->addChild(
                $location->id,
                array(
                    'label' => $this->translationHelper->getTranslatedContentNameByContentInfo($location->contentInfo),
                    'uri' => $this->router->generate($location),
                    'attributes' => array('id' => 'nav-location-' . $location->id),
                )
            );
            $menuItem->setChildrenAttribute('class', 'nav');
        }
    }
827261
public function showOnlyCurrentChildren(ItemInterface $menu)
    {
        $itemIterator = new RecursiveItemIterator($menu->getIterator());

        $iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($iterator as $menuItem) {
            /** @var \Knp\Menu\MenuItem $menuItem */
            if (!$this->matcher->isCurrent($menuItem) && !$this->matcher->isAncestor($menuItem)) {
                $menuItem->setDisplayChildren(false);
            }
        }
    }
737624
public function fileEdit($file, $search, $replace)
    {
        file_put_contents($file, str_replace(
            $search,
            $replace,
            file_get_contents($file)
        ));
    }
379470
def update_search_menu(self):
        """"""
        # Disabling all actions except the last one
        # (which is Find in files) to begin with
        for child in self.search_menu.actions()[:-1]:
            child.setEnabled(False)

        widget, textedit_properties = self.get_focus_widget_properties()
        if textedit_properties is None: # widget is not an editor/console
            return

        # !!! Below this line, widget is expected to be a QPlainTextEdit
        #     instance
        console, not_readonly, readwrite_editor = textedit_properties

        # Find actions only trigger an effect in the Editor
        if not console:
            for action in self.search_menu.actions():
                try:
                    action.setEnabled(True)
                except RuntimeError:
                    pass

        # Disable the replace action for read-only files
        self.search_menu_actions[3].setEnabled(readwrite_editor)
1116882
function add ($title, $text, $menu, $footer, $lang, $id=null)
    {
        global $config;
        $this->title=$title;
        $this->content=$text;
        if (isset($id)) {
            $query = sprintf(
                file_get_contents("sql/addPageID.sql"),
                mysql_real_escape_string($title),
                mysql_real_escape_string($text), mysql_real_escape_string($menu),
                mysql_real_escape_string($footer), $lang, $id
            );
        } else {
            $query = sprintf(
                file_get_contents("sql/addPage.sql"),
                mysql_real_escape_string($title),
                mysql_real_escape_string($text), mysql_real_escape_string($menu),
                mysql_real_escape_string($footer), $lang
            );
        }
        $config->connexionBdd->requete($query);
    }
207221
protected static function _clear($menu)
    {
        if (array_key_exists($menu, self::$_items)) {
            self::$_items[$menu] = [];
        } else {
            throw new \UnexpectedValueException('Invalid menu: ' . $menu);
        }
    }
687326
private function addLayoutsSubMenu(ItemInterface $menu): void
    {
        $menuOrder = $this->getNewMenuOrder($menu);

        $layouts = $menu
            ->addChild('nglayouts')
            ->setLabel('menu.main_menu.header')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layout_resolver', ['route' => 'ngbm_admin_layout_resolver_index'])
            ->setLabel('menu.main_menu.layout_resolver')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('layouts', ['route' => 'ngbm_admin_layouts_index'])
            ->setLabel('menu.main_menu.layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $layouts
            ->addChild('shared_layouts', ['route' => 'ngbm_admin_shared_layouts_index'])
            ->setLabel('menu.main_menu.shared_layouts')
            ->setExtra('translation_domain', 'ngbm_admin');

        $menu->reorderChildren($menuOrder);
    }
1319964
public function addAdaptMenu(MenuAdaptorInterface $adaptor, $priority = 0)
    {
        $this->adaptors[$priority][] = $adaptor;
        unset($this->sorted);
    }
220851
public void addItemsAtPosition(int position, @NonNull IDrawerItem... drawerItems) {
        mDrawerBuilder.getItemAdapter().add(position, drawerItems);
    }
583585
public function add(ItemInterface $item)
    {
        if ($this->has($item->getId()) === true) {
            throw new \RuntimeException(sprintf('A previous item exists with the same id: "%s".', $item->getId()));
        }

        $this->set($item);
    }
967534
public void replaceMenuById(SubMenuItem subMenu, MenuItem toReplace) {
        synchronized (subMenuItems) {
            ArrayList<MenuItem> list = subMenuItems.get(subMenu);
            int idx = -1;
            for (int i = 0; i < list.size(); ++i) {
                if (list.get(i).getId() == toReplace.getId()) {
                    idx = i;
                }
            }

            if (idx != -1) {
                MenuItem oldItem = list.set(idx, toReplace);
                if (toReplace.hasChildren()) {
                    ArrayList<MenuItem> items = subMenuItems.remove(oldItem);
                    subMenuItems.put(toReplace, items);
                }
            }

        }
    }
112040
public function addMenu(Menu $menu)
    {
        $menu->setArticle($this);
        $this->menus[] = $menu;

        return $this;
    }
746791
public function newPlacementAction(Request $request, $newMenuItemId, $menuItemId)
    {
        $sibling = $request->get('sibling');

        /** @var MenuItemManager $menuItemManager */
        $menuItemManager = $this->get('networking_init_cms.menu_item_manager');
        $newMenuItem = $menuItemManager->find($newMenuItemId);
        $menuItem = $menuItemManager->find($menuItemId);

        if (!$newMenuItem || !$menuItem) {
            throw new NotFoundHttpException();
        }

        $data = [];
        try {
            if ($sibling) {
                $menuItemManager->persistAsNextSiblingOf($newMenuItem, $menuItem);
            } else {
                $menuItemManager->persistAsFirstChildOf($newMenuItem, $menuItem);
            }
            $this->getDoctrine()->getManager()->flush();
            $data = [
                'result' => 'ok',
                'objectId' => $this->admin->getNormalizedIdentifier($newMenuItem),
            ];

            return $this->renderJson($data);
        } catch (\Exception $e) {
            return $this->renderJson($data);
        }
    }
399775
public void moveItem(SubMenuItem parent, MenuItem newItem, MoveType moveType) {
        synchronized (subMenuItems) {
            ArrayList<MenuItem> items = subMenuItems.get(parent);
            int idx = items.indexOf(newItem);
            if(idx < 0) return;

            items.remove(idx);

            idx = (moveType == MoveType.MOVE_UP)? --idx : ++idx;
            if(idx<0) idx=0;

            if(idx>=items.size()) {
                items.add(newItem);
            }
            else {
                items.add(idx, newItem);
            }
        }
    }
700378
public function prePersist(MenuInterface $menu, LifecycleEventArgs $event)
    {
        if (null !== $page = $menu->getPage()) {
            $menu->setRoute($page->getRoute());
        }
        if (!preg_match(self::NAME_REGEX, $menu->getName())) {
            $menu->setName(Transliterator::urlize(strtolower($menu->getName()), '_'));
        }
    }
356986
public function addItemFactory(ItemFactoryInterface $itemFactory)
    {
        $class = get_class($itemFactory);

        if (isset($this->itemFactories[$class])) {
            throw new MenuException(sprintf('Item factory "%s" already added to menu.', $class));
        }

        $this->itemFactories[$class] = $itemFactory;
    }
246994
protected function addLinkRoute(ItemInterface $menu, $label, $route, $routeParameters = array())
    {
        $item = $menu->addChild($label, array('route' => $route, 'routeParameters' => $routeParameters));
        $item->setExtra('translation_domain', $this->translation_domain);

        if ($item->getUri() == $this->container->get('request')->getRequestUri()) {
            $item->setAttribute('class', 'active');
        }

        return $item;
    }