You are here

class RouteSubscriber in Color API 8

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of RouteSubscriber

1 string reference to 'RouteSubscriber'
colorapi.services.yml in ./colorapi.services.yml
colorapi.services.yml

File

src/Routing/RouteSubscriber.php, line 11

Namespace

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

Namesort descending Modifiers Type Description Overrides
RouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
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