Skip to content
Snippets Groups Projects

Convert patch to MR.

Open Thomas Fleming requested to merge issue/drupal-2918231:2918231-enforce-bundle into 11.x
1 unresolved thread
Files
3
@@ -53,6 +53,18 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager) {
public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
[$entity_type, $bundle] = explode(':', $route->getRequirement($this->requirementsKey) . ':');
// For an entity type that has bundles, the $bundle must be specified.
$entity_type_definition = $this->entityTypeManager->getDefinition($entity_type);
if (empty($bundle) && $entity_type_definition && $entity_type_definition->hasKey('bundle')) {
@trigger_error(
sprintf(
'Defining a \'%s\' route requirement without a bundle for an entity type which has bundles (%s) is deprecated in drupal:11.2.0 and will be disallowed in drupal:12.0.0. Specify a bundle, either as a string or as a route parameter placeholder, in the route requirement. See https://www.drupal.org/node/3505093',
$this->requirementsKey,
$entity_type,
), E_USER_DEPRECATED
);
}
// The bundle argument can contain request argument placeholders like
// {name}, loop over the raw variables and attempt to replace them in the
// bundle name. If a placeholder does not exist, it won't get replaced.
Loading