public static function fromSerialized(string $definition, string $tabId): self
    {
        $navigation = new Navigation();
        $current    = $navigation;
        $definition = StringUtil::deserialize($definition, true);
        $cssIds     = [];

        foreach ($definition as $index => $tab) {
            if (!$tab['cssId']) {
                $tab['cssId']  = StringUtil::standardize($tab['title']);
                $tab['cssId'] .= '-' . $tabId;

                if (in_array($tab['cssId'], $cssIds)) {
                    $tab['cssId'] .= '-' . $index;
                }
            }

            if ($tab['type'] === 'dropdown') {
                $item    = Dropdown::fromArray($tab);
                $current = $item;

                $navigation->addItem($item);
            } else {
                if ($tab['type'] !== 'child') {
                    $current = $navigation;
                }

                $item = NavItem::fromArray($tab);
                $current->addItem($item);
            }
        }

        return $navigation;
    }
public static function fromSerialized(string $definition, string $tabId): self
    {
        $navigation = new Navigation();
        $current    = $navigation;
        $definition = StringUtil::deserialize($definition, true);
        $cssIds     = [];

        foreach ($definition as $index => $tab) {
            if (!$tab['cssId']) {
                $tab['cssId']  = StringUtil::standardize($tab['title']);
                $tab['cssId'] .= '-' . $tabId;

                if (in_array($tab['cssId'], $cssIds)) {
                    $tab['cssId'] .= '-' . $index;
                }
            }

            if ($tab['type'] === 'dropdown') {
                $item    = Dropdown::fromArray($tab);
                $current = $item;

                $navigation->addItem($item);
            } else {
                if ($tab['type'] !== 'child') {
                    $current = $navigation;
                }

                $item = NavItem::fromArray($tab);
                $current->addItem($item);
            }
        }

        return $navigation;
    }
public static function fromSerialized ( string $ definition , string $ tabId ) : self { $ navigation = new Navigation ( ) ; $ current = $ navigation ; $ definition = StringUtil :: deserialize ( $ definition , true ) ; $ cssIds = [ ] ; foreach ( $ definition as $ index => $ tab ) { if ( ! $ tab [ 'cssId' ] ) { $ tab [ 'cssId' ] = StringUtil :: standardize ( $ tab [ 'title' ] ) ; $ tab [ 'cssId' ] .= '-' . $ tabId ; if ( in_array ( $ tab [ 'cssId' ] , $ cssIds ) ) { $ tab [ 'cssId' ] .= '-' . $ index ; } } if ( $ tab [ 'type' ] === 'dropdown' ) { $ item = Dropdown :: fromArray ( $ tab ) ; $ current = $ item ; $ navigation -> addItem ( $ item ) ; } else { if ( $ tab [ 'type' ] !== 'child' ) { $ current = $ navigation ; } $ item = NavItem :: fromArray ( $ tab ) ; $ current -> addItem ( $ item ) ; } } return $ navigation ; }
Create instance from a serialized definition

@param string $definition Serialized definition.
@param string $tabId      Tab id as string, used as css id suffix.

@return Navigation
Create instance from a serialized definition