diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index f737571..6b5284f 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -435,6 +435,13 @@ public function hasFormClasses() { /** * {@inheritdoc} */ + public function hasRouteProviders() { + return !empty($this->handlers['route_provider']); + } + + /** + * {@inheritdoc} + */ public function getListBuilderClass() { return $this->getHandlerClass('list_builder'); } diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index d6640b1..9c3a58e 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -280,6 +280,13 @@ public function setFormClass($operation, $class); public function hasFormClasses(); /** + * Indicates if this entity type has any route provider. + * + * @return bool + */ + public function hasRouteProviders(); + + /** * Gets all the route provide handlers. * * Much like forms you can define multiple route provider handlers. diff --git a/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php b/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php index 1f99cc7..7d07cd6 100644 --- a/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php +++ b/core/lib/Drupal/Core/Entity/Routing/EntityRouteProviderInterface.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity\Routing; use Drupal\Core\Entity\EntityTypeInterface; -use Symfony\Component\Routing\RouteCollection; /** * Allows entity types to provide routes. diff --git a/core/lib/Drupal/Core/EventSubscriber/EntityRouteProviderSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EntityRouteProviderSubscriber.php index 98a6a49..ff1b4b3 100644 --- a/core/lib/Drupal/Core/EventSubscriber/EntityRouteProviderSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/EntityRouteProviderSubscriber.php @@ -37,11 +37,14 @@ public function __construct(EntityManagerInterface $entity_manager) { /** * Provide routes on route rebuild time. + * + * @param \Drupal\Core\Routing\RouteBuildEvent $event + * The route build event. */ public function onDynamic(RouteBuildEvent $event) { $route_collection = $event->getRouteCollection(); foreach ($this->entityManager->getDefinitions() as $entity_type) { - if ($entity_type->hasHandlerClass('route_provider', TRUE)) { + if ($entity_type->hasRouteProviders()) { foreach ($this->entityManager->getRouteProviders($entity_type->id()) as $route_provider) { // Allow to both return an array of routes or a route collection, // like route_callbacks in the routing.yml file.