Pagekit\Widget\Controller\WidgetApiController::indexAction PHP Method

indexAction() public method

public indexAction ( )
    public function indexAction()
    {
        $widgets = Widget::findAll();
        $positions = App::position()->all();
        foreach ($positions as &$position) {
            $position['widgets'] = [];
            foreach ($position['assigned'] as $id) {
                if (isset($widgets[$id])) {
                    $position['widgets'][] = $widgets[$id];
                    unset($widgets[$id]);
                }
            }
        }
        return ['positions' => array_values($positions), 'unassigned' => array_values($widgets)];
    }