class NodeRouteProvider

Same name in other branches
  1. 9 core/modules/node/src/Entity/NodeRouteProvider.php \Drupal\node\Entity\NodeRouteProvider
  2. 8.9.x core/modules/node/src/Entity/NodeRouteProvider.php \Drupal\node\Entity\NodeRouteProvider
  3. 10 core/modules/node/src/Entity/NodeRouteProvider.php \Drupal\node\Entity\NodeRouteProvider

Provides routes for nodes.

Hierarchy

Expanded class hierarchy of NodeRouteProvider

File

core/modules/node/src/Entity/NodeRouteProvider.php, line 13

Namespace

Drupal\node\Entity
View source
class NodeRouteProvider implements EntityRouteProviderInterface {
    
    /**
     * {@inheritdoc}
     */
    public function getRoutes(EntityTypeInterface $entity_type) {
        $route_collection = new RouteCollection();
        $route = (new Route('/node/{node}'))->addDefaults([
            '_controller' => '\\Drupal\\node\\Controller\\NodeViewController::view',
            '_title_callback' => '\\Drupal\\node\\Controller\\NodeViewController::title',
        ])
            ->setRequirement('node', '\\d+')
            ->setRequirement('_entity_access', 'node.view');
        $route_collection->add('entity.node.canonical', $route);
        $route = (new Route('/node/{node}/delete'))->addDefaults([
            '_entity_form' => 'node.delete',
            '_title' => 'Delete',
        ])
            ->setRequirement('node', '\\d+')
            ->setRequirement('_entity_access', 'node.delete')
            ->setOption('_node_operation_route', TRUE);
        $route_collection->add('entity.node.delete_form', $route);
        $route = (new Route('/node/{node}/edit'))->setDefault('_entity_form', 'node.edit')
            ->setRequirement('_entity_access', 'node.update')
            ->setRequirement('node', '\\d+')
            ->setOption('_node_operation_route', TRUE);
        $route_collection->add('entity.node.edit_form', $route);
        return $route_collection;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
NodeRouteProvider::getRoutes public function Provides routes for entities. Overrides EntityRouteProviderInterface::getRoutes

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.