class DevelRouteSubscriber in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 modules/search_api_solr_devel/src/Routing/DevelRouteSubscriber.php \Drupal\search_api_solr_devel\Routing\DevelRouteSubscriber
- 4.x modules/search_api_solr_devel/src/Routing/DevelRouteSubscriber.php \Drupal\search_api_solr_devel\Routing\DevelRouteSubscriber
Subscriber for Search Api Solr routes.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\search_api_solr_devel\Routing\DevelRouteSubscriber
Expanded class hierarchy of DevelRouteSubscriber
1 string reference to 'DevelRouteSubscriber'
- search_api_solr_devel.services.yml in search_api_solr_devel/
search_api_solr_devel.services.yml - search_api_solr_devel/search_api_solr_devel.services.yml
1 service uses DevelRouteSubscriber
File
- search_api_solr_devel/
src/ Routing/ DevelRouteSubscriber.php, line 15
Namespace
Drupal\search_api_solr_devel\RoutingView source
class DevelRouteSubscriber extends RouteSubscriberBase {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new RouteSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityTypeManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($route = $this
->getDevelSolrRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.devel_solr", $route);
}
}
}
/**
* Gets the devel Solr route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getDevelSolrRoute(EntityTypeInterface $entity_type) {
if ($devel_solr = $entity_type
->getLinkTemplate('devel-solr')) {
$entity_type_id = $entity_type
->id();
$route = new Route($devel_solr);
$route
->addDefaults([
'_controller' => '\\Drupal\\search_api_solr_devel\\Controller\\DevelController::entitySolr',
'_title' => 'Devel Solr',
])
->addRequirements([
'_permission' => 'access devel information',
])
->setOption('_admin_route', TRUE)
->setOption('_devel_entity_type_id', $entity_type_id)
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
return $route;
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
100,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DevelRouteSubscriber:: |
protected | property | The entity type manager service. | |
DevelRouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
DevelRouteSubscriber:: |
protected | function | Gets the devel Solr route. | |
DevelRouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
DevelRouteSubscriber:: |
public | function | Constructs a new RouteSubscriber object. | |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |