You are here

SupportTicketAdminRouteSubscriber.php in Support Ticketing System 8

File

modules/support_ticket/src/EventSubscriber/SupportTicketAdminRouteSubscriber.php
View source
<?php

/**
 * @file
 * Contains \Drupal\support_ticket\EventSubscriber\SupportTicketAdminRouteSubscriber.
 */
namespace Drupal\support_ticket\EventSubscriber;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Sets the _admin_route for specific support ticket-related routes.
 */
class SupportTicketAdminRouteSubscriber extends RouteSubscriberBase {

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

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

}

Classes

Namesort descending Description
SupportTicketAdminRouteSubscriber Sets the _admin_route for specific support ticket-related routes.