You are here

class ImceRouteSubscriber in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/Routing/ImceRouteSubscriber.php \Drupal\imce\Routing\ImceRouteSubscriber

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of ImceRouteSubscriber

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

File

src/Routing/ImceRouteSubscriber.php, line 12

Namespace

Drupal\imce\Routing
View source
class ImceRouteSubscriber extends RouteSubscriberBase {

  /**
   * The constructor method.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The constructor method.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   Defines the configuration object factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {

    // Conditionally declare imce.page an admin route.
    if ($route = $collection
      ->get('imce.page')) {
      $config = $this->configFactory
        ->get('imce.settings');
      if ($config
        ->get('admin_theme')) {
        $route
          ->setOption('_admin_route', TRUE);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ImceRouteSubscriber::$configFactory protected property The constructor method.
ImceRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
ImceRouteSubscriber::__construct public function The constructor method.
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