class YamlFormRouteSubscriber in YAML Form 8
Adds the _admin_route option to form routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\yamlform\Routing\YamlFormRouteSubscriber
Expanded class hierarchy of YamlFormRouteSubscriber
1 string reference to 'YamlFormRouteSubscriber'
1 service uses YamlFormRouteSubscriber
File
- src/
Routing/ YamlFormRouteSubscriber.php, line 11
Namespace
Drupal\yamlform\RoutingView source
class YamlFormRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection
->all() as $route) {
if (!$route
->hasOption('_admin_route') && (strpos($route
->getPath(), '/admin/structure/yamlform/') === 0 || strpos($route
->getPath(), '/yamlform/results/') !== FALSE)) {
$route
->setOption('_admin_route', TRUE);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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 |
YamlFormRouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |