all() as $route) { if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) { $placeholders = array('@variables' => implode(', ', $not_allowed_variables)); drupal_set_message(String::format('The following variables are reserved names by drupal: @variables', $placeholders)); watchdog('error', 'The following variables are reserved names by drupal: @variables', $placeholders); return FALSE; } } return TRUE; } /** * Delegates the route altering to self::alterRoutes(). * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The route build event. * * @return bool * Returns TRUE if the variables were successfully replaced, otherwise * FALSE. */ public function onAlterRoutes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); return $this->alterRoutes($collection, $event->getProvider()); } }