src/Charcoal/Admin/Widget/FormSidebarWidget.php
protected function parseAsSidebarActions(array $actions)
    {
        $sidebarActions = [];
        foreach ($actions as $ident => $action) {
            $ident  = $this->parseActionIdent($ident, $action);
            $action = $this->parseActionItem($action, $ident, true);

            if (!isset($action['priority'])) {
                $action['priority'] = $this->actionsPriority++;
            }

            if ($action['ident'] === 'view' && !$this->isObjViewable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'save' && !$this->isObjSavable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'reset' && !$this->isObjResettable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'delete' && !$this->isObjDeletable()) {
                $action['active'] = false;
            }

            if ($action['isSubmittable'] && !$this->isObjSavable()) {
                $action['active'] = false;
            }

            if ($action['actions']) {
                $action['actions']    = $this->parseAsSidebarActions($action['actions']);
                $action['hasActions'] = !!array_filter($action['actions'], function ($action) {
                    return $action['active'];
                });
            }

            if (isset($sidebarActions[$ident])) {
                $hasPriority = ($action['priority'] > $sidebarActions[$ident]['priority']);
                if ($hasPriority || $action['isSubmittable']) {
                    $sidebarActions[$ident] = array_replace($sidebarActions[$ident], $action);
                } else {
                    $sidebarActions[$ident] = array_replace($action, $sidebarActions[$ident]);
                }
            } else {
                $sidebarActions[$ident] = $action;
            }
        }

        usort($sidebarActions, [ $this, 'sortActionsByPriority' ]);

        while (($first = reset($sidebarActions)) && $first['isSeparator']) {
            array_shift($sidebarActions);
        }

        while (($last = end($sidebarActions)) && $last['isSeparator']) {
            array_pop($sidebarActions);
        }

        return $sidebarActions;
    }
protected function parseAsSidebarActions(array $actions)
    {
        $sidebarActions = [];
        foreach ($actions as $ident => $action) {
            $ident  = $this->parseActionIdent($ident, $action);
            $action = $this->parseActionItem($action, $ident, true);

            if (!isset($action['priority'])) {
                $action['priority'] = $this->actionsPriority++;
            }

            if ($action['ident'] === 'view' && !$this->isObjViewable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'save' && !$this->isObjSavable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'reset' && !$this->isObjResettable()) {
                $action['active'] = false;
            } elseif ($action['ident'] === 'delete' && !$this->isObjDeletable()) {
                $action['active'] = false;
            }

            if ($action['isSubmittable'] && !$this->isObjSavable()) {
                $action['active'] = false;
            }

            if ($action['actions']) {
                $action['actions']    = $this->parseAsSidebarActions($action['actions']);
                $action['hasActions'] = !!array_filter($action['actions'], function ($action) {
                    return $action['active'];
                });
            }

            if (isset($sidebarActions[$ident])) {
                $hasPriority = ($action['priority'] > $sidebarActions[$ident]['priority']);
                if ($hasPriority || $action['isSubmittable']) {
                    $sidebarActions[$ident] = array_replace($sidebarActions[$ident], $action);
                } else {
                    $sidebarActions[$ident] = array_replace($action, $sidebarActions[$ident]);
                }
            } else {
                $sidebarActions[$ident] = $action;
            }
        }

        usort($sidebarActions, [ $this, 'sortActionsByPriority' ]);

        while (($first = reset($sidebarActions)) && $first['isSeparator']) {
            array_shift($sidebarActions);
        }

        while (($last = end($sidebarActions)) && $last['isSeparator']) {
            array_pop($sidebarActions);
        }

        return $sidebarActions;
    }
protected function parseAsSidebarActions ( array $ actions ) { $ sidebarActions = [ ] ; foreach ( $ actions as $ ident => $ action ) { $ ident = $ this -> parseActionIdent ( $ ident , $ action ) ; $ action = $ this -> parseActionItem ( $ action , $ ident , true ) ; if ( ! isset ( $ action [ 'priority' ] ) ) { $ action [ 'priority' ] = $ this -> actionsPriority ++ ; } if ( $ action [ 'ident' ] === 'view' && ! $ this -> isObjViewable ( ) ) { $ action [ 'active' ] = false ; } elseif ( $ action [ 'ident' ] === 'save' && ! $ this -> isObjSavable ( ) ) { $ action [ 'active' ] = false ; } elseif ( $ action [ 'ident' ] === 'reset' && ! $ this -> isObjResettable ( ) ) { $ action [ 'active' ] = false ; } elseif ( $ action [ 'ident' ] === 'delete' && ! $ this -> isObjDeletable ( ) ) { $ action [ 'active' ] = false ; } if ( $ action [ 'isSubmittable' ] && ! $ this -> isObjSavable ( ) ) { $ action [ 'active' ] = false ; } if ( $ action [ 'actions' ] ) { $ action [ 'actions' ] = $ this -> parseAsSidebarActions ( $ action [ 'actions' ] ) ; $ action [ 'hasActions' ] = ! ! array_filter ( $ action [ 'actions' ] , function ( $ action ) { return $ action [ 'active' ] ; } ) ; } if ( isset ( $ sidebarActions [ $ ident ] ) ) { $ hasPriority = ( $ action [ 'priority' ] > $ sidebarActions [ $ ident ] [ 'priority' ] ) ; if ( $ hasPriority || $ action [ 'isSubmittable' ] ) { $ sidebarActions [ $ ident ] = array_replace ( $ sidebarActions [ $ ident ] , $ action ) ; } else { $ sidebarActions [ $ ident ] = array_replace ( $ action , $ sidebarActions [ $ ident ] ) ; } } else { $ sidebarActions [ $ ident ] = $ action ; } } usort ( $ sidebarActions , [ $ this , 'sortActionsByPriority' ] ) ; while ( ( $ first = reset ( $ sidebarActions ) ) && $ first [ 'isSeparator' ] ) { array_shift ( $ sidebarActions ) ; } while ( ( $ last = end ( $ sidebarActions ) ) && $ last [ 'isSeparator' ] ) { array_pop ( $ sidebarActions ) ; } return $ sidebarActions ; }
Parse the given actions as object actions.

@param  array $actions Actions to resolve.
@return array
Parse the given actions as object actions .