Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 13 |
RouteSubscriber | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 13 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
alterRoutes | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
getSubscribedEvents | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\config_translation\Routing\RouteSubscriber. | |
*/ | |
namespace Drupal\config_translation\Routing; | |
use Drupal\Core\Routing\RouteSubscriberBase; | |
use Drupal\config_translation\ConfigMapperManagerInterface; | |
use Drupal\Core\Routing\RoutingEvents; | |
use Symfony\Component\Routing\RouteCollection; | |
/** | |
* Listens to the dynamic route events. | |
*/ | |
class RouteSubscriber extends RouteSubscriberBase { | |
/** | |
* The mapper plugin discovery service. | |
* | |
* @var \Drupal\config_translation\ConfigMapperManagerInterface | |
*/ | |
protected $mapperManager; | |
/** | |
* Constructs a new RouteSubscriber. | |
* | |
* @param \Drupal\config_translation\ConfigMapperManagerInterface $mapper_manager | |
* The mapper plugin discovery service. | |
*/ | |
public function __construct(ConfigMapperManagerInterface $mapper_manager) { | |
$this->mapperManager = $mapper_manager; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
protected function alterRoutes(RouteCollection $collection) { | |
$mappers = $this->mapperManager->getMappers($collection); | |
foreach ($mappers as $mapper) { | |
$collection->add($mapper->getOverviewRouteName(), $mapper->getOverviewRoute()); | |
$collection->add($mapper->getAddRouteName(), $mapper->getAddRoute()); | |
$collection->add($mapper->getEditRouteName(), $mapper->getEditRoute()); | |
$collection->add($mapper->getDeleteRouteName(), $mapper->getDeleteRoute()); | |
} | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public static function getSubscribedEvents() { | |
// Come after field_ui. | |
$events[RoutingEvents::ALTER] = array('onAlterRoutes', -110); | |
return $events; | |
} | |
} |