From 78ec28a9d383835189944104fc280e0f20ef3165 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Wed, 28 Feb 2024 10:09:17 +0000 Subject: [PATCH] Issue #3415938 by longwave, Spokje, taraskorpach: Remove ContainerAwareTrait from CacheFactory and ChainedFastBackendFactory --- core/lib/Drupal/Core/Cache/CacheFactory.php | 19 +++++++++++---- .../Core/Cache/ChainedFastBackendFactory.php | 16 ++++++++++--- core/phpstan-baseline.neon | 24 ------------------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheFactory.php b/core/lib/Drupal/Core/Cache/CacheFactory.php index 845014581b40..9b65b9b27295 100644 --- a/core/lib/Drupal/Core/Cache/CacheFactory.php +++ b/core/lib/Drupal/Core/Cache/CacheFactory.php @@ -6,12 +6,9 @@ * Defines the cache backend factory. */ use Drupal\Core\Site\Settings; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; +use Psr\Container\ContainerInterface; -class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface { - - use ContainerAwareTrait; +class CacheFactory implements CacheFactoryInterface { /** * The site settings. @@ -44,6 +41,18 @@ class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface { */ protected $memoryDefaultBinBackends; + /** + * The service container. + */ + protected ContainerInterface $container; + + /** + * Sets the service container. + */ + public function setContainer(ContainerInterface $container): void { + $this->container = $container; + } + /** * Constructs CacheFactory object. * diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php index 5df7ae1ce4b0..6109806eec94 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php @@ -4,7 +4,7 @@ use Drupal\Core\Installer\InstallerKernel; use Drupal\Core\Site\Settings; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; +use Psr\Container\ContainerInterface; /** * Defines the chained fast cache backend factory. @@ -13,8 +13,6 @@ */ class ChainedFastBackendFactory implements CacheFactoryInterface { - use ContainerAwareTrait; - /** * The service name of the consistent backend factory. * @@ -29,6 +27,18 @@ class ChainedFastBackendFactory implements CacheFactoryInterface { */ protected $fastServiceName; + /** + * The service container. + */ + protected ContainerInterface $container; + + /** + * Sets the service container. + */ + public function setContainer(ContainerInterface $container): void { + $this->container = $container; + } + /** * Constructs ChainedFastBackendFactory object. * diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 248968fa05fd..d968d46bc86c 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -237,30 +237,6 @@ parameters: count: 1 path: lib/Drupal/Core/Block/BlockManager.php - - - message: """ - #^Class Drupal\\\\Core\\\\Cache\\\\CacheFactory implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\: - since Symfony 6\\.4, use dependency injection instead$# - """ - count: 1 - path: lib/Drupal/Core/Cache/CacheFactory.php - - - - message: """ - #^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Cache\\\\CacheFactory\\: - since Symfony 6\\.4, use dependency injection instead$# - """ - count: 1 - path: lib/Drupal/Core/Cache/CacheFactory.php - - - - message: """ - #^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Cache\\\\ChainedFastBackendFactory\\: - since Symfony 6\\.4, use dependency injection instead$# - """ - count: 1 - path: lib/Drupal/Core/Cache/ChainedFastBackendFactory.php - - message: "#^Constructor of class Drupal\\\\Core\\\\Cache\\\\NullBackend has an unused parameter \\$bin\\.$#" count: 1 -- GitLab