class SpecialAttributesRouteSubscriber in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php \Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber
Provides a route subscriber which checks for invalid pattern variables.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements EventSubscriberInterface
- class \Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber
Expanded class hierarchy of SpecialAttributesRouteSubscriber
1 file declares its use of SpecialAttributesRouteSubscriber
- SpecialAttributesRouteSubscriberTest.php in core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ SpecialAttributesRouteSubscriberTest.php - Contains \Drupal\Tests\Core\EventSubscriber\SpecialAttributesRouteSubscriberTest.
1 string reference to 'SpecialAttributesRouteSubscriber'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses SpecialAttributesRouteSubscriber
File
- core/
lib/ Drupal/ Core/ EventSubscriber/ SpecialAttributesRouteSubscriber.php, line 18 - Contains \Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber.
Namespace
Drupal\Core\EventSubscriberView source
class SpecialAttributesRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$special_variables = array(
'system_path',
'_legacy',
'_raw_variables',
RouteObjectInterface::ROUTE_OBJECT,
RouteObjectInterface::ROUTE_NAME,
'_content',
'_controller',
'_form',
);
foreach ($collection
->all() as $name => $route) {
if ($not_allowed_variables = array_intersect($route
->compile()
->getVariables(), $special_variables)) {
$reserved = implode(', ', $not_allowed_variables);
trigger_error(sprintf('Route %s uses reserved variable names: %s', $name, $reserved), E_USER_WARNING);
}
}
}
/**
* Delegates the route altering to self::alterRoutes().
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The route build event.
*/
public function onAlterRoutes(RouteBuildEvent $event) {
$collection = $event
->getRouteCollection();
$this
->alterRoutes($collection);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriberBase:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides EventSubscriberInterface:: |
5 |
SpecialAttributesRouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
SpecialAttributesRouteSubscriber:: |
public | function |
Delegates the route altering to self::alterRoutes(). Overrides RouteSubscriberBase:: |