You are here

class LogAdminRouteSubscriber in Log entity 8

Sets the _admin_route for specific log-related routes.

Hierarchy

Expanded class hierarchy of LogAdminRouteSubscriber

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

File

src/EventSubscriber/LogAdminRouteSubscriber.php, line 17
Contains \Drupal\log\EventSubscriber\LogAdminRouteSubscriber.

Namespace

Drupal\log\EventSubscriber
View source
class LogAdminRouteSubscriber extends RouteSubscriberBase {

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

  /**
   * Constructs a new LogAdminRouteSubscriber.
   *
   * @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('log.settings')
      ->get('log_use_admin_theme')) {
      foreach ($collection
        ->all() as $route) {
        if ($route
          ->hasOption('_log_operation_route')) {
          $route
            ->setOption('_admin_route', TRUE);
        }
      }
    }
  }

}

Members

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