class RouteSubscriber in Color API 8
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\colorapi\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
File
- src/
Routing/ RouteSubscriber.php, line 11
Namespace
Drupal\colorapi\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$colorapi_color_entity_routes = [
'entity.colorapi_color.collection',
'entity.colorapi_color.add_form',
'entity.colorapi_color.edit_form',
'entity.colorapi_color.delete_form',
];
foreach ($colorapi_color_entity_routes as $route_name) {
if ($route = $collection
->get($route_name)) {
$color_entity_enabled = \Drupal::config('colorapi.settings')
->get('enable_color_entity');
if (!$color_entity_enabled) {
$collection
->remove($route_name);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | 5 |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |