luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
812 stars 207 forks source link

Remove admin\base\Module menu builder methods and replace with AdminMenuBuilder class #1045

Closed nadar closed 8 years ago

nadar commented 8 years ago

In order to make the admin menu build process more flexible an AdminMenuBuilder class should replace the protected methods (node, group, itemApi , etc.) inside the admin base module class.

Therfore the bootstrap process has been changed in order to run only in admin context.

nadar commented 8 years ago

Upgrade info inside of the admin modules getMenu() function:

Change this:

 public function getMenu()
    {
        return $this
            ->nodeRoute('menu_node_cms', 'content_copy', 'cmsadmin-default-index', 'cmsadmin/default/index', 'luya\cms\models\NavItem')
            ->node('menu_node_cmssettings', 'settings')
                ->group('menu_group_env')
                    ->itemRoute('menu_group_item_env_permission', "cmsadmin/permission/index", 'gavel')
                    ->itemApi('menu_group_item_env_container', 'cmsadmin-navcontainer-index', 'label_outline', 'api-cms-navcontainer')
                    ->itemApi('menu_group_item_env_layouts', 'cmsadmin-layout-index', 'view_quilt', 'api-cms-layout')
                ->group('menu_group_elements')
                    ->itemApi('menu_group_item_elements_group', 'cmsadmin-blockgroup-index', 'view_module', 'api-cms-blockgroup')
                    ->itemApi('menu_group_item_elements_blocks', 'cmsadmin-block-index', 'format_align_left', 'api-cms-block')
            ->menu();
    }

To:

public function getMenu()
    {
        return (new AdminMenuBuilder($this))
            ->nodeRoute('menu_node_cms', 'content_copy', 'cmsadmin-default-index', 'cmsadmin/default/index', 'luya\cms\models\NavItem')
            ->node('menu_node_cmssettings', 'settings')
                ->group('menu_group_env')
                    ->itemRoute('menu_group_item_env_permission', "cmsadmin/permission/index", 'gavel')
                    ->itemApi('menu_group_item_env_container', 'cmsadmin-navcontainer-index', 'label_outline', 'api-cms-navcontainer')
                    ->itemApi('menu_group_item_env_layouts', 'cmsadmin-layout-index', 'view_quilt', 'api-cms-layout')
                ->group('menu_group_elements')
                    ->itemApi('menu_group_item_elements_group', 'cmsadmin-blockgroup-index', 'view_module', 'api-cms-blockgroup')
                    ->itemApi('menu_group_item_elements_blocks', 'cmsadmin-block-index', 'format_align_left', 'api-cms-block');
    }