Skip to content
Snippets Groups Projects

Issue #3501727: Remove the deprication notice, remove the entity type manager...

Closed Mariusz Andrzejewski requested to merge issue/drupal-3501727:3501727-try-to-simplify into 11.x
Files
4
@@ -3,6 +3,7 @@
namespace Drupal\user\Theme;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\AdminContext;
use Drupal\Core\Routing\RouteMatchInterface;
@@ -13,6 +14,12 @@
* Sets the active theme on admin pages.
*/
class AdminNegotiator implements ThemeNegotiatorInterface {
use DeprecatedServicePropertyTrait;
/**
* The service properties that should raise a deprecation error.
*/
private array $deprecatedProperties = ['entityTypeManager' => 'entity_type.manager'];
/**
* The current user.
@@ -28,13 +35,6 @@ class AdminNegotiator implements ThemeNegotiatorInterface {
*/
protected $configFactory;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The route admin context to determine whether a route is an admin one.
*
@@ -49,23 +49,29 @@ class AdminNegotiator implements ThemeNegotiatorInterface {
* The current user.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Routing\AdminContext $admin_context
* @param \Drupal\Core\Routing\AdminContext|EntityTypeManagerInterface $admin_context
* The route admin context to determine whether the route is an admin one.
*/
public function __construct(AccountInterface $user, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, AdminContext $admin_context) {
public function __construct(AccountInterface $user, ConfigFactoryInterface $config_factory, AdminContext|EntityTypeManagerInterface $admin_context) {
$this->user = $user;
$this->configFactory = $config_factory;
$this->entityTypeManager = $entity_type_manager;
$this->adminContext = $admin_context;
if ($admin_context instanceof EntityTypeManagerInterface) {
$deprecated_service_name = EntityTypeManagerInterface::class;
@trigger_error("Passing the $deprecated_service_name (entity_type.manager service) to AdminNegotiator is deprecated in drupal:11.2.0 and will be removed in drupal:12.0.0. There is no replacement for this service, as it is not used. See https://www.drupal.org/project/drupal/issues/3501727", E_USER_DEPRECATED);
$this->adminContext = \Drupal::service('router.admin_context');
}
else {
$this->adminContext = $admin_context;
}
}
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return ($this->entityTypeManager->hasHandler('user_role', 'storage') && $this->user->hasPermission('view the administration theme') && $this->adminContext->isAdminRoute($route_match->getRouteObject()));
$is_admin_route = $this->adminContext->isAdminRoute($route_match->getRouteObject());
return $is_admin_route && $this->user->hasPermission('view the administration theme');
}
/**
Loading