You are here

class YamlFormRouteSubscriber in YAML Form 8

Adds the _admin_route option to form routes.

Hierarchy

Expanded class hierarchy of YamlFormRouteSubscriber

1 string reference to 'YamlFormRouteSubscriber'
yamlform.services.yml in ./yamlform.services.yml
yamlform.services.yml
1 service uses YamlFormRouteSubscriber
yamlform.route_subscriber in ./yamlform.services.yml
Drupal\yamlform\Routing\YamlFormRouteSubscriber

File

src/Routing/YamlFormRouteSubscriber.php, line 11

Namespace

Drupal\yamlform\Routing
View 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

Namesort descending Modifiers Type Description Overrides
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1
YamlFormRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes