Jump to content

Issue with adding back office side menu tab


Recommended Posts

Hello guys,

 

I had trouble using this part of the documentation: https://devdocs.prestashop.com/1.7/modules/concepts/controllers/admin-controllers/tabs/#automatic-tab-registration

Because for me it just does not work for some reason. And IMO the example given in the documentation does not make any sense, why would you use the "AdminLinkWidget" as a legacy controller ?

When we create a tab we want to create a specific link linked to a specific custom controller.

 

So the automatic registration did not work, I had to create the tab manually

private function installTab(): bool
    {
        $tabId = (int) Tab::getIdFromClassName('MyAdminController');
        if (!$tabId) {
            $tabId = null;
        }

        $tab = new Tab($tabId);
        $tab->active = 1;
        $tab->class_name = 'MyAdminController';
        $tab->route_name = 'instaev_admin_gallery_index';
        $tab->name = [];
        foreach (Language::getLanguages() as $lang) {
            $tab->name[$lang['id_lang']] = 'Instaev';
        }
        $tab->id_parent = (int) Tab::getIdFromClassName('CONFIGURE');

        return $tab->save();
    }
instaev_admin_gallery_index:
  path: /instaev/home
  defaults:
    _controller: Hdclic\Instaev\Controller\GalleryController::indexAction
    _legacy_controller: MyAdminController
    _legacy_link: MyAdminController

So instead of the AdminLinkWidget, I used my own. (MyAdminController).

 

But I really would like to understand why the automatic registration does not work for me, and I want to implement it.

 

The main issues I have triying to do it is

@AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.")

which triggers an error because it seems I do not have the access it seems eventhough the install went well all the time. And the tab is not created on the side.

Do you guys have the same issue ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More