You are here

class EckEntityAdminRouteSubscriber in Entity Construction Kit (ECK) 8

Sets the _admin_route for specific eck-related routes.

Hierarchy

Expanded class hierarchy of EckEntityAdminRouteSubscriber

1 string reference to 'EckEntityAdminRouteSubscriber'
eck.services.yml in ./eck.services.yml
eck.services.yml
1 service uses EckEntityAdminRouteSubscriber
eck.admin_path.route_subscriber in ./eck.services.yml
Drupal\eck\EventSubscriber\EckEntityAdminRouteSubscriber

File

src/EventSubscriber/EckEntityAdminRouteSubscriber.php, line 12

Namespace

Drupal\eck\EventSubscriber
View source
class EckEntityAdminRouteSubscriber extends RouteSubscriberBase {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new EckEntityAdminRouteSubscriber.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($this->configFactory
      ->get('eck.settings')
      ->get('use_admin_theme')) {
      foreach ($collection
        ->all() as $route) {
        if ($route
          ->hasOption('_eck_operation_route')) {
          $route
            ->setOption('_admin_route', TRUE);
        }
      }
    }
  }

}

Members

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