Score:1

Format of callback arguments in YAML files

ke flag

For instance, for the Filter module, in filter.permissions.yml, custom permissions are defined:

permission_callbacks:
  - Drupal\filter\FilterPermissions::permissions

That looks like a static function, but it isn't. How does that work? Is the format for this kind of callback argument documented or defined anywhere?

Score:3
ke flag

I believe that this is a Symfony format. I can't find it in the documentation, but this talks about it https://symfonycasts.com/screencast/deep-dive/controller-setup

I found the code (or some code) in https://api.drupal.org/api/drupal/vendor%21symfony%21http-kernel%21Controller%21ControllerResolver.php/9.1.x

The Symfony Controller code explodes the string around the '::' into $class and $method and figures out if it's $classobject->$method() or $class::$method().

Score:0
de flag

Documentation is here: https://api.drupal.org/api/drupal/core%21modules%21user%21src%21PermissionHandler.php/class/PermissionHandler/9.1.x

If your module needs to define dynamic permissions you can use the permission_callbacks key to declare a callable that will return an array of permissions, keyed by machine name. Each item in the array can contain the same keys as an entry in $module.permissions.yml.

ke flag
Permissions are just an example
Jaypan avatar
de flag
Then your question is not clear, as I answered what you asked.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.