diff --git a/core/lib/Drupal/Core/Entity/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index a48e2e0..399963f 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -7,6 +7,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\DependencyInjection\ClassResolverInterface; use Drupal\Core\Entity\Exception\InvalidLinkTemplateException; +use Drupal\Core\Entity\Routing\EntityUuidRouteProviderInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; @@ -84,7 +85,9 @@ public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); // Add the UUID link template if applicable. - if ($definition->hasKey('uuid') && $definition->hasViewBuilderClass()) { + $route_providers = $definition->getRouteProviderClasses(); + $has_uuid_route = isset($route_providers['html']) && in_array(EntityUuidRouteProviderInterface::class, class_implements($route_providers['html']), TRUE); + if ($definition->hasKey('uuid') && $definition->hasViewBuilderClass() && $has_uuid_route) { $definition->setLinkTemplate('uuid', "/{$plugin_id}/{{$plugin_id}}"); } // All link templates must have a leading slash. diff --git a/core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php b/core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php index 6c712f5..c0f1afa 100644 --- a/core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php +++ b/core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php @@ -30,7 +30,7 @@ * * @internal */ -class DefaultHtmlRouteProvider implements EntityRouteProviderInterface, EntityHandlerInterface { +class DefaultHtmlRouteProvider implements EntityUuidRouteProviderInterface, EntityHandlerInterface { /** * The entity type manager. diff --git a/core/lib/Drupal/Core/Entity/Routing/EntityUuidRouteProviderInterface.php b/core/lib/Drupal/Core/Entity/Routing/EntityUuidRouteProviderInterface.php new file mode 100644 index 0000000..704d834 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/Routing/EntityUuidRouteProviderInterface.php @@ -0,0 +1,10 @@ +execute(); - foreach ($nids as $nid) { - foreach ($node_links[$nid] as $key => $link) { - $node_links[$nid][$key]->access = $access_result; + if ($nids) { + foreach ($nids as $nid) { + if (isset($node_links[$nid])) { + foreach ($node_links[$nid] as $key => $link) { + $node_links[$nid][$key]->access = $access_result; + } + } } } } diff --git a/core/modules/node/src/Entity/NodeRouteProvider.php b/core/modules/node/src/Entity/NodeRouteProvider.php index b46b09d..327afbc 100644 --- a/core/modules/node/src/Entity/NodeRouteProvider.php +++ b/core/modules/node/src/Entity/NodeRouteProvider.php @@ -4,14 +4,14 @@ use Drupal\Component\Uuid\Uuid; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Routing\EntityRouteProviderInterface; +use Drupal\Core\Entity\Routing\EntityUuidRouteProviderInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * Provides routes for nodes. */ -class NodeRouteProvider implements EntityRouteProviderInterface { +class NodeRouteProvider implements EntityUuidRouteProviderInterface { /** * {@inheritdoc} diff --git a/core/modules/user/src/Entity/UserRouteProvider.php b/core/modules/user/src/Entity/UserRouteProvider.php index 14543bb..d6e3c0f 100644 --- a/core/modules/user/src/Entity/UserRouteProvider.php +++ b/core/modules/user/src/Entity/UserRouteProvider.php @@ -4,14 +4,14 @@ use Drupal\Component\Uuid\Uuid; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Routing\EntityRouteProviderInterface; +use Drupal\Core\Entity\Routing\EntityUuidRouteProviderInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; /** * Provides routes for the user entity. */ -class UserRouteProvider implements EntityRouteProviderInterface { +class UserRouteProvider implements EntityUuidRouteProviderInterface { /** * {@inheritdoc} diff --git a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php index 6639a24..e3c1478 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php @@ -286,7 +286,7 @@ public function providerTestGetUuidRoute() { ]) ->setRequirements([ '_entity_access' => 'the_entity_type_id.view', - 'the_entity_type_id' => '/^' . Uuid::VALID_PATTERN . '$/', + 'the_entity_type_id' => '^' . Uuid::VALID_PATTERN . '$', ]) ->setOptions([ 'parameters' => [