By larowlan on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
12.1.x
Introduced in version:
12.1.0
Issue links:
Description:
From Drupal 12.1.0 onwards, creating an instance of the menu tree storage service without passing the route provider is deprecated.
It will be required from Drupal 13.0
Example from core:
Before:
<?php
use Drupal\Core\Menu\MenuTreeStorage as CoreMenuTreeStorage;
/**
* Overrides the default menu storage to provide workspace-specific menu links.
*
* @internal
*/
class WorkspacesMenuTreeStorage extends CoreMenuTreeStorage {
/**
* WorkspacesMenuTreeStorage constructor.
*
* @param \Drupal\workspaces\WorkspaceManagerInterface $workspaceManager
* The workspace manager service.
* @param \Drupal\workspaces\WorkspaceAssociationInterface $workspaceAssociation
* The workspace association service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Database\Connection $connection
* A Database connection to use for reading and writing configuration data.
* @param \Drupal\Core\Cache\CacheBackendInterface $menu_cache_backend
* Cache backend instance for the extracted tree data.
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
* @param string $table
* A database table name to store configuration data in.
* @param array $options
* (optional) Any additional database connection options to use in queries.
*/
public function __construct(
protected readonly WorkspaceManagerInterface $workspaceManager,
protected readonly WorkspaceAssociationInterface $workspaceAssociation,
protected readonly EntityTypeManagerInterface $entityTypeManager,
Connection $connection,
CacheBackendInterface $menu_cache_backend,
CacheTagsInvalidatorInterface $cache_tags_invalidator,
string $table,
array $options = [],
) {
parent::__construct($connection, $menu_cache_backend, $cache_tags_invalidator, $table, $options);
}
After:
<?php
use Drupal\Core\Menu\MenuTreeStorage as CoreMenuTreeStorage;
use Drupal\Core\Routing\RouteProviderInterface;
/**
* Overrides the default menu storage to provide workspace-specific menu links.
*
* @internal
*/
class WorkspacesMenuTreeStorage extends CoreMenuTreeStorage {
/**
* WorkspacesMenuTreeStorage constructor.
*
* @param \Drupal\workspaces\WorkspaceManagerInterface $workspaceManager
* The workspace manager service.
* @param \Drupal\workspaces\WorkspaceAssociationInterface $workspaceAssociation
* The workspace association service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Database\Connection $connection
* A Database connection to use for reading and writing configuration data.
* @param \Drupal\Core\Cache\CacheBackendInterface $menu_cache_backend
* Cache backend instance for the extracted tree data.
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
* The cache tags invalidator.
* @param string $table
* A database table name to store configuration data in.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* Route provider.
* @param array $options
* (optional) Any additional database connection options to use in queries.
*/
public function __construct(
protected readonly WorkspaceManagerInterface $workspaceManager,
protected readonly WorkspaceAssociationInterface $workspaceAssociation,
protected readonly EntityTypeManagerInterface $entityTypeManager,
Connection $connection,
CacheBackendInterface $menu_cache_backend,
CacheTagsInvalidatorInterface $cache_tags_invalidator,
string $table,
RouteProviderInterface $route_provider,
array $options = [],
) {
parent::__construct($connection, $menu_cache_backend, $cache_tags_invalidator, $table, $route_provider, $options);
}
Impacts:
Module developers