CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
A deep dive into Drupal 8 routing
1. A Deep Dive into Drupal
8 Routing
DrupalCamp Mumbai
April 1, 2017
Naveen Valecha
2. About me
● Drupal: naveenvalecha
● Git Administer on Drupal.org
● Site Maintainer of groups.drupal.org
● Twitter: @_naveenvalecha_
● Web: https://www.valechatech.net
● Drupal 5,6,7,8
3. Agenda
● What are Routes. Why we need them?
● Routes and Controllers
● Access checking on routes
● Custom Access Checkers
● CSRF Prevention on routes
● Altering routes
● Dynamic Routes
● Parameter Upcasting
4. Routing System
● hook_menu to Symfony2 routing
● Replace paths with route names for rendering
links
● Converting all page callbacks to controllers
● New breadcrumb system, new menu link system,
conversion of local tasks and actions to plugins
5. Routing System - Cont.
● menu links, local tasks, local actions, contextual
links
● Split all the pieces from hook_menu into YAML
files finally
● module.routing.yml module.links.menu.yml
● module.links.task.yml module.links.action.yml
● module.contextual.yml
6. hook_menu to Symfony Routing
● PHP array to multiple yaml files
● Performance improvements
● Developer Experience(DX)
● Clean Code
● Procedural to Object Oriented(OO)
10. Route
● A route is a path which is defined for Drupal to
return some sort of content on. For example, the
default front page, '/node' is a route.
● Use mm.routing.yml for defining routes
11. Routes and Controllers
● The routing system is responsible for matching
paths to controllers, and you define those
relations in routes. You can pass on additional
information to your controllers in the route.
Access checking is integrated as well.
25. Route-Parameter Upcasting Cont.
class NodePreviewConverter implements ParamConverterInterface {
public function convert($value, $definition, $name, array $defaults) {
$store = $this->tempStoreFactory->get('node_preview');
if ($form_state = $store->get($value)) {
return $form_state->getFormObject()->getEntity();
}
}
public function applies($definition, $name, Route $route) {
if (!empty($definition['type']) && $definition['type'] == 'node_preview') {
return TRUE;
}
return FALSE;
}
26. What’s for Drupal 9?
● Consider having a single class for Match Dumper,
Route Provider and Route Builder
● Automatically unserialize request data and
serialize outgoing data