Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\node\EventSubscriber; | |
4 | |
5 use Drupal\Core\Config\ConfigFactoryInterface; | |
6 use Drupal\Core\Routing\RouteSubscriberBase; | |
7 use Symfony\Component\Routing\RouteCollection; | |
8 | |
9 /** | |
10 * Sets the _admin_route for specific node-related routes. | |
11 */ | |
12 class NodeAdminRouteSubscriber extends RouteSubscriberBase { | |
13 | |
14 /** | |
15 * The config factory. | |
16 * | |
17 * @var \Drupal\Core\Config\ConfigFactoryInterface | |
18 */ | |
19 protected $configFactory; | |
20 | |
21 /** | |
22 * Constructs a new NodeAdminRouteSubscriber. | |
23 * | |
24 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory | |
25 * The config factory. | |
26 */ | |
27 public function __construct(ConfigFactoryInterface $config_factory) { | |
28 $this->configFactory = $config_factory; | |
29 } | |
30 | |
31 /** | |
32 * {@inheritdoc} | |
33 */ | |
34 protected function alterRoutes(RouteCollection $collection) { | |
35 if ($this->configFactory->get('node.settings')->get('use_admin_theme')) { | |
36 foreach ($collection->all() as $route) { | |
37 if ($route->hasOption('_node_operation_route')) { | |
38 $route->setOption('_admin_route', TRUE); | |
39 } | |
40 } | |
41 } | |
42 } | |
43 | |
44 } |