I'm trying to fully understand Drupal 8 routing. I understand the basics, no problem, but some of the finer details are still a mystery.

Here's the route for adding a node from the node module.

  path: '/node/add/{node_type}'
    _controller: '\Drupal\node\Controller\NodeController::add'
    _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
    _node_add_access: 'node:{node_type}'
    _node_operation_route: TRUE
        with_config_overrides: TRUE

I'm struggling with the line _node_add_access: 'node:{node_type}'.

I understand what the _node_add_access key does. It refers to a service with a tag of applies_to: _node_add_access. That is provided by the NodeAddAccessCheck class.

What does the node:{node_type} do? No amount of tracing through code has answered that for me. It looks to be a unique value for some purpose. Is it related to caching?

I haven't got to the options stuff yet.


EDIT: I'm not sure if this should be an answer but these applies_to requirements seem to be read in Drupal\Core\Access\CheckProvider::applies and the value (e.g. node:{node_type}) doesn't seem to be used at all.

2 Answers 2


That definition isn't about what is passed to NodeAddAccessCheck, that is solely defined by the slug definition in the path and the type hinted argument.

Instead, it is configuration for its implementation. Which it doesn't actually use. So yes, it is pointless. See \Drupal\Core\Entity\EntityCreateAccessCheck for an access check that actually uses that definition to dynamically get the value it wants from the route match parameters.

I suppose this initially used that and was switch to a different implementation, without removing the now unnecessary configuration.

  • Thanks, that explains it. I got onto this because I was studying a contrib module and noticed it doing the same thing but not using the value.
    – tetranz
    Commented Jul 7, 2016 at 22:17

{node_type} is a slug and is available as the $node_type param in NodeAddAccessCheck::access()


  • I thought that too but I don't think that's it. There's an arguments resolver which gets the node_type from the request. I can replace node:{node_type} in the yml with something completely bogus ('xxx') and it still works. NodeAddAccessCheck::access() still receives a NodeType object.
    – tetranz
    Commented Jul 7, 2016 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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