-2

I am writing a custom module that adds a configImportForm with two options and I've assigned it to a user and given a specific permission - I want to disable the import / export tasks and just show my import config task

I've tried alter hooks and preprocessing nothing is working has anyone tried/done this before?

1 Answer 1

2

You don't need to do anything special for your local task, just add proper permission requirements on your route, and the local task will follow:

See https://www.drupal.org/node/2092643#section-requirements

your_module.routing.yml:

protected.route:
  path: '/your-module'
  requirements:
    _permission: 'your custom permission'
5
  • Id tried adding a permission to my routing.yml file I have import export ignore in configuration synchronisation and I am adding a import config task if import config task is there I don't want the other import does that make sense?
    – DigiDev
    Commented Jul 25 at 20:32
  • Err... no? Local tasks have nothing to do with config import/export
    – Hudri
    Commented Jul 25 at 20:35
  • I have local tasks of import / export / ignore What I am trying to achieve is that I have a configImportForm that I have built I have created a permission I am seeing my form where I want it to be but I need to hide the other tasks if I have a role with the permission access configuration form 2 Does this make more sense?
    – DigiDev
    Commented Jul 25 at 20:38
  • 1
    I think you mean the links in the UI, i.e. those found at /admin/config/development/configuration? If so, you need to add an event subscriber and override the access with your own callback - drupal.org/docs/drupal-apis/routing-system/… has quite a lot of useful information
    – Clive
    Commented Jul 25 at 22:46
  • @clive yes maybe I do mean those links. I am still learning Drupal Thank you for this comment. I will have a look at the documentation. Still learning all the functionalities of it all! Commented Jul 25 at 23:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.