src/Netzmacht/Bootstrap/Buttons/Factory.php
public static function createFromFieldset($definition)
    {
        $definition = self::parseDefinition($definition);
        $root       = new Group();
        $group      = $root;

        /** @var bool|Dropdown $dropdown */
        $dropdown = false;
        $first    = true;

        foreach ($definition as $button) {
            // dont add empty items
            if (self::isInvalidDefinition($button)) {
                continue;
            }

            // encode value
            $button = self::encodeValue($button);

            // finish dropdown
            if (self::hasToCloseDropdown($dropdown, $button)) {
                $dropdown = false;
            }

            if (in_array($button['type'], array('group', 'vgroup'))) {
                // create new group
                $group = self::createNewGroup($root, $button, $dropdown, !$first);
            } elseif ($button['type'] == 'dropdown') {
                // create dropdown

                $dropdown      = static::createDropdown($button['label'], $button['attributes'], true);
                $dropdownGroup = static::createGroup();
                $dropdownGroup->addChild($dropdown);

                $group->addChild($dropdownGroup);
            } elseif ($button['type'] == 'child' || $button['type'] == 'header') {
                // add dropdown child

                static::parseDropdownChild($dropdown, $button);
            } elseif ($dropdown !== false) {
                $child = static::createDropdownItem($button['label'], $button['url'], $button['attributes'], true);
                $dropdown->addChild($child);
            } else {
                $child = static::createButton($button['label'], $button['url'], $button['attributes'], true);
                $group->addChild($child);
            }

            $first = false;
        }

        return $root;
    }
public static function createFromFieldset($definition)
    {
        $definition = self::parseDefinition($definition);
        $root       = new Group();
        $group      = $root;

        /** @var bool|Dropdown $dropdown */
        $dropdown = false;
        $first    = true;

        foreach ($definition as $button) {
            // dont add empty items
            if (self::isInvalidDefinition($button)) {
                continue;
            }

            // encode value
            $button = self::encodeValue($button);

            // finish dropdown
            if (self::hasToCloseDropdown($dropdown, $button)) {
                $dropdown = false;
            }

            if (in_array($button['type'], array('group', 'vgroup'))) {
                // create new group
                $group = self::createNewGroup($root, $button, $dropdown, !$first);
            } elseif ($button['type'] == 'dropdown') {
                // create dropdown

                $dropdown      = static::createDropdown($button['label'], $button['attributes'], true);
                $dropdownGroup = static::createGroup();
                $dropdownGroup->addChild($dropdown);

                $group->addChild($dropdownGroup);
            } elseif ($button['type'] == 'child' || $button['type'] == 'header') {
                // add dropdown child

                static::parseDropdownChild($dropdown, $button);
            } elseif ($dropdown !== false) {
                $child = static::createDropdownItem($button['label'], $button['url'], $button['attributes'], true);
                $dropdown->addChild($child);
            } else {
                $child = static::createButton($button['label'], $button['url'], $button['attributes'], true);
                $group->addChild($child);
            }

            $first = false;
        }

        return $root;
    }
public static function createFromFieldset ( $ definition ) { $ definition = self :: parseDefinition ( $ definition ) ; $ root = new Group ( ) ; $ group = $ root ; /** @var bool|Dropdown $dropdown */ $ dropdown = false ; $ first = true ; foreach ( $ definition as $ button ) { // dont add empty items if ( self :: isInvalidDefinition ( $ button ) ) { continue ; } // encode value $ button = self :: encodeValue ( $ button ) ; // finish dropdown if ( self :: hasToCloseDropdown ( $ dropdown , $ button ) ) { $ dropdown = false ; } if ( in_array ( $ button [ 'type' ] , array ( 'group' , 'vgroup' ) ) ) { // create new group $ group = self :: createNewGroup ( $ root , $ button , $ dropdown , ! $ first ) ; } elseif ( $ button [ 'type' ] == 'dropdown' ) { // create dropdown $ dropdown = static :: createDropdown ( $ button [ 'label' ] , $ button [ 'attributes' ] , true ) ; $ dropdownGroup = static :: createGroup ( ) ; $ dropdownGroup -> addChild ( $ dropdown ) ; $ group -> addChild ( $ dropdownGroup ) ; } elseif ( $ button [ 'type' ] == 'child' || $ button [ 'type' ] == 'header' ) { // add dropdown child static :: parseDropdownChild ( $ dropdown , $ button ) ; } elseif ( $ dropdown !== false ) { $ child = static :: createDropdownItem ( $ button [ 'label' ] , $ button [ 'url' ] , $ button [ 'attributes' ] , true ) ; $ dropdown -> addChild ( $ child ) ; } else { $ child = static :: createButton ( $ button [ 'label' ] , $ button [ 'url' ] , $ button [ 'attributes' ] , true ) ; $ group -> addChild ( $ child ) ; } $ first = false ; } return $ root ; }
Create button from fieldset defintiion.

@param string|array $definition Button definition.

@return Group|Toolbar
Create button from fieldset defintiion .