support-2.0.x-dev/modules/support_ticket/src/EventSubscriber/SupportTicketAdminRouteSubscriber.php
modules/support_ticket/src/EventSubscriber/SupportTicketAdminRouteSubscriber.php
<?php
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);
}
}
}
}
}
