July 2017
Intermediate to advanced
456 pages
11h 32m
English
The simplest way to provide routes is to define them in your module's routing YAML file. Not all routes can be known ahead of time and specified this way. By adding a route_callbacks entry in your routing YAML file as an array, callables that return a list of routes. For example adding:
route_callbacks: - '\Drupal\mastering_drupal_8\Routing\TestRoutes::routes'
If we were to create the same route as above, that file would look like:
/** * Defines dynamic routes. */class TestRoutes { /** * {@inheritdoc} */ public function routes() { $routes = array(); // Declares a single route under the name'mastering_drupal_8.test_page'. // Returns an array of Route objects. $routes['mastering_drupal_8.test_page'] = new Route( // Path to ...Read now
Unlock full access