Backend\Core\Installer\ModuleInstaller::setNavigation PHP Метод

setNavigation() защищенный Метод

Set a new navigation item.
protected setNavigation ( integer $parentId, string $label, string $url = '', array $selectedFor = null, integer $sequence = null ) : integer
$parentId integer Id of the navigation item under we should add this.
$label string Label for the item.
$url string Url for the item. If omitted the first child is used.
$selectedFor array Set selected when these actions are active.
$sequence integer Sequence to use for this item.
Результат integer
    protected function setNavigation($parentId, $label, $url = '', array $selectedFor = null, $sequence = null)
    {
        $parentId = (int) $parentId;
        $label = (string) $label;
        $url = (string) $url;
        $selectedFor = $selectedFor !== null && is_array($selectedFor) ? serialize($selectedFor) : null;
        // no custom sequence
        if ($sequence === null) {
            // get maximum sequence for this parent
            $maxSequence = (int) $this->getDB()->getVar('SELECT MAX(sequence)
                 FROM backend_navigation
                 WHERE parent_id = ?', array($parentId));
            // add at the end
            $sequence = $maxSequence + 1;
        } else {
            $sequence = (int) $sequence;
        }
        // get the id for this url
        $id = (int) $this->getDB()->getVar('SELECT id
             FROM backend_navigation
             WHERE parent_id = ? AND label = ? AND url = ?', array($parentId, $label, $url));
        // doesn't exist yet, add it
        if ($id === 0) {
            return $this->getDB()->insert('backend_navigation', array('parent_id' => $parentId, 'label' => $label, 'url' => $url, 'selected_for' => $selectedFor, 'sequence' => $sequence));
        }
        // already exists so return current id
        return $id;
    }