Routing system

Routing system in Drupal 8.

Routing system overview

High level overview of what the routing system is and how it works.

Introductory Drupal 8 routes and controllers example

This is a quick introduction to routes and controllers in Drupal 8. If you're only modifying or extending existing functionality, you may

Structure of routes

Overview of required, and optional properties of a route definition.

Access checking on routes

Simple access checking with permissions/roles

Altering existing routes and adding new routes based on dynamic ones

Any route - whether statically defined in a YAML file, as seen in the introductory example, or a dynamic route as described in Providing

Parameters in routes

Drupal 8's routes may include placeholder elements which designate places where the URL contains dynamic values. In the controller method

Parameter upcasting in routes

Drupal 8's routes may include placeholder elements which designate places where the URL contains dynamic values. By naming these

Using parameters in routes

Use a named parameter if you need to refer to a content or configuration entity type in the route path. For example in example.routing.yml:

Accessing raw values

If you need to access the unconverted data, like for example a user ID, you can access the data using $request->attributes->get('_raw

Implementing custom parameter converters

It should be very rare that you need custom parameter converters, because all content and configuration entities automatically get upcast,

Parameters values validation in routes

Drupal 8's routes placeholder values (i.e. parameters passed in the URL) may be validated using the routing system. Placeholder values could

How a node ID gets converted to its actual node object

There are a couple of tagged services ('route_enhancer') which changes the values in the request attributes.

Providing dynamic routes

The simplest way to provide routes is to define them in a routing YAML file named after the module, as seen in the introductory example. Not

Routing-related objects: Route, CurrentRouteMatch, RouteMatch, Url

Route, CurrentRouteMatch, RouteMatch, Url are objects used for routing in Drupal 8.

Underlying functionality of the routing system in Drupal 8

The Drupal 8 routing system builds a great deal on the Symfony framework. To define and use routes, you don't necessarily need to know the