src/Charcoal/Admin/Widget/SecondaryMenuWidget.php
public function addGroup($groupIdent, $group)
    {
        if (!is_string($groupIdent)) {
            throw new InvalidArgumentException(
                'Group identifier must be a string'
            );
        }

        if ($group instanceof SecondaryMenuGroupInterface) {
            $group->setSecondaryMenu($this);
            $group->setIdent($groupIdent);

            $this->groups[] = $group;
        } elseif (is_array($group)) {
            if (isset($group['ident'])) {
                $groupIdent = $group['ident'];
            } else {
                $group['ident'] = $groupIdent;
            }

            $displayOptions = $this->displayOptions();
            if (isset($group['display_options'])) {
                $displayOptions = array_merge($displayOptions, $group['display_options']);
            }

            $group['collapsed'] = $displayOptions['collapsed'];
            $group['parented']  = $displayOptions['parented'];

            if (!isset($group['display_type'])) {
                $group['display_type'] = $this->displayType();
            }

            $collapsible = ($group['display_type'] === 'collapsible');

            if ($collapsible) {
                $group['group_id'] = uniqid('collapsible_');
            }

            $g = $this->secondaryMenu()->create($this->defaultGroupType());
            $g->setSecondaryMenu($this);
            $g->setData($group);

            $group = $g;
        } elseif ($group === false || $group === null) {
            return $this;
        } else {
            throw new InvalidArgumentException(sprintf(
                'Group must be an instance of %s or an array of form group options, received %s',
                'SecondaryMenuGroupInterface',
                (is_object($group) ? get_class($group) : gettype($group))
            ));
        }

        if ($g->isAuthorized() === false) {
            return $this;
        }

        $this->groups[] = $g;

        return $this;
    }
public function addGroup($groupIdent, $group)
    {
        if (!is_string($groupIdent)) {
            throw new InvalidArgumentException(
                'Group identifier must be a string'
            );
        }

        if ($group instanceof SecondaryMenuGroupInterface) {
            $group->setSecondaryMenu($this);
            $group->setIdent($groupIdent);

            $this->groups[] = $group;
        } elseif (is_array($group)) {
            if (isset($group['ident'])) {
                $groupIdent = $group['ident'];
            } else {
                $group['ident'] = $groupIdent;
            }

            $displayOptions = $this->displayOptions();
            if (isset($group['display_options'])) {
                $displayOptions = array_merge($displayOptions, $group['display_options']);
            }

            $group['collapsed'] = $displayOptions['collapsed'];
            $group['parented']  = $displayOptions['parented'];

            if (!isset($group['display_type'])) {
                $group['display_type'] = $this->displayType();
            }

            $collapsible = ($group['display_type'] === 'collapsible');

            if ($collapsible) {
                $group['group_id'] = uniqid('collapsible_');
            }

            $g = $this->secondaryMenu()->create($this->defaultGroupType());
            $g->setSecondaryMenu($this);
            $g->setData($group);

            $group = $g;
        } elseif ($group === false || $group === null) {
            return $this;
        } else {
            throw new InvalidArgumentException(sprintf(
                'Group must be an instance of %s or an array of form group options, received %s',
                'SecondaryMenuGroupInterface',
                (is_object($group) ? get_class($group) : gettype($group))
            ));
        }

        if ($g->isAuthorized() === false) {
            return $this;
        }

        $this->groups[] = $g;

        return $this;
    }
public function addGroup ( $ groupIdent , $ group ) { if ( ! is_string ( $ groupIdent ) ) { throw new InvalidArgumentException ( 'Group identifier must be a string' ) ; } if ( $ group instanceof SecondaryMenuGroupInterface ) { $ group -> setSecondaryMenu ( $ this ) ; $ group -> setIdent ( $ groupIdent ) ; $ this -> groups [ ] = $ group ; } elseif ( is_array ( $ group ) ) { if ( isset ( $ group [ 'ident' ] ) ) { $ groupIdent = $ group [ 'ident' ] ; } else { $ group [ 'ident' ] = $ groupIdent ; } $ displayOptions = $ this -> displayOptions ( ) ; if ( isset ( $ group [ 'display_options' ] ) ) { $ displayOptions = array_merge ( $ displayOptions , $ group [ 'display_options' ] ) ; } $ group [ 'collapsed' ] = $ displayOptions [ 'collapsed' ] ; $ group [ 'parented' ] = $ displayOptions [ 'parented' ] ; if ( ! isset ( $ group [ 'display_type' ] ) ) { $ group [ 'display_type' ] = $ this -> displayType ( ) ; } $ collapsible = ( $ group [ 'display_type' ] === 'collapsible' ) ; if ( $ collapsible ) { $ group [ 'group_id' ] = uniqid ( 'collapsible_' ) ; } $ g = $ this -> secondaryMenu ( ) -> create ( $ this -> defaultGroupType ( ) ) ; $ g -> setSecondaryMenu ( $ this ) ; $ g -> setData ( $ group ) ; $ group = $ g ; } elseif ( $ group === false || $ group === null ) { return $ this ; } else { throw new InvalidArgumentException ( sprintf ( 'Group must be an instance of %s or an array of form group options, received %s' , 'SecondaryMenuGroupInterface' , ( is_object ( $ group ) ? get_class ( $ group ) : gettype ( $ group ) ) ) ) ; } if ( $ g -> isAuthorized ( ) === false ) { return $ this ; } $ this -> groups [ ] = $ g ; return $ this ; }
Add a secondary menu group.

@param  string                            $groupIdent The group identifier.
@param  array|SecondaryMenuGroupInterface $group      The group object or structure.
@throws InvalidArgumentException If the identifier is not a string or the group is invalid.
@return self
Add a secondary menu group .