From c7b214f53a58e1c8764cbda912445a0ce3975362 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Sun, 26 May 2024 11:26:16 +0200
Subject: [PATCH] [TASK] Use PHP attributes more often to configure DI
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Using PHP attributes to configure DI within classes
directly is more easy to understand since developers
don't need to constantly look up DI configuration
Services.yaml files, but have everything in one place.

The patch switches all classes that previously
used '@cache.xy' to get a specific cache injected
to an `Autowire` attribute.

Resolves: #103921
Releases: main
Change-Id: I16b064242cdbc2bbcfbed89700c97afac012fdf8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84406
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
---
 .../backend/Classes/Backend/Avatar/Avatar.php |  4 ++
 .../ContentSecurityPolicyHeaders.php          | 12 ++--
 .../backend/Configuration/Services.yaml       |  9 ---
 .../Extension/ExtLocalconfFactory.php         | 10 +++-
 .../Extension/ExtTablesFactory.php            | 10 +++-
 .../Classes/Configuration/Tca/TcaFactory.php  | 12 ++--
 .../SoftReferenceParserFactory.php            | 21 +++----
 .../ProviderConfigurationLoader.php           | 13 ++--
 .../core/Classes/Page/ImportMapFactory.php    |  5 ++
 .../sysext/core/Classes/Page/PageRenderer.php |  3 +-
 .../Service/MarkerBasedTemplateService.php    | 11 +++-
 .../TypoScript/PageTsConfigFactory.php        | 14 +++--
 .../TypoScript/UserTsConfigFactory.php        | 14 +++--
 typo3/sysext/core/Configuration/Services.yaml | 60 ++-----------------
 .../dashboard/Classes/Widgets/RssWidget.php   |  6 +-
 .../Backend/DashboardWidgets.yaml             |  2 -
 .../Configuration/WidgetRegistration.rst      |  2 -
 .../Developer/MakeRefreshable.rst             |  1 -
 .../Documentation/Widgets/RssWidget.rst       |  6 --
 .../BackendConfigurationManager.php           |  5 ++
 .../ClassesConfigurationFactory.php           | 22 +++----
 .../extbase/Configuration/Services.yaml       | 11 ----
 .../Classes/Service/TranslationService.php    |  4 ++
 typo3/sysext/form/Configuration/Services.yaml |  5 --
 .../Classes/Cache/CacheLifetimeCalculator.php |  4 ++
 .../ContentSecurityPolicyHeaders.php          | 14 +++--
 .../PrepareTypoScriptFrontendRendering.php    |  3 +
 .../frontend/Classes/Typolink/LinkFactory.php |  4 ++
 .../frontend/Configuration/Services.yaml      | 19 ------
 .../Controller/RecyclerAjaxController.php     |  2 +
 .../recycler/Configuration/Services.yaml      |  4 --
 .../Classes/Service/RedirectService.php       |  2 +
 .../redirects/Configuration/Services.yaml     |  4 --
 .../Classes/Repository/WebhookRepository.php  |  2 +
 .../webhooks/Configuration/Services.yaml      |  5 --
 35 files changed, 134 insertions(+), 191 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Backend/Avatar/Avatar.php b/typo3/sysext/backend/Classes/Backend/Avatar/Avatar.php
index 3c4b12c95bae..599af0ccefa0 100644
--- a/typo3/sysext/backend/Classes/Backend/Avatar/Avatar.php
+++ b/typo3/sysext/backend/Classes/Backend/Avatar/Avatar.php
@@ -17,6 +17,8 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Backend\Backend\Avatar;
 
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -31,6 +33,7 @@ use TYPO3\CMS\Core\Utility\PathUtility;
  *
  * See render() and getImgTag() as main entry points
  */
+#[Autoconfigure(public: true)]
 class Avatar
 {
     /**
@@ -41,6 +44,7 @@ class Avatar
     protected array $avatarProviders = [];
 
     public function __construct(
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $cache,
         protected readonly DependencyOrderingService $dependencyOrderingService,
         protected readonly IconFactory $iconFactory
diff --git a/typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php b/typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php
index 5a6a0e9fb594..0fdf4c59bb0e 100644
--- a/typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php
+++ b/typo3/sysext/backend/Classes/Middleware/ContentSecurityPolicyHeaders.php
@@ -22,6 +22,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface;
 use Psr\Log\LoggerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\RequestId;
 use TYPO3\CMS\Core\Security\ContentSecurityPolicy\PolicyProvider;
@@ -33,13 +34,14 @@ use TYPO3\CMS\Core\Security\ContentSecurityPolicy\UriValue;
  *
  * @internal
  */
-final class ContentSecurityPolicyHeaders implements MiddlewareInterface
+final readonly class ContentSecurityPolicyHeaders implements MiddlewareInterface
 {
     public function __construct(
-        private readonly RequestId $requestId,
-        private readonly LoggerInterface $logger,
-        private readonly FrontendInterface $cache,
-        private readonly PolicyProvider $policyProvider,
+        private RequestId $requestId,
+        private LoggerInterface $logger,
+        #[Autowire(service: 'cache.assets')]
+        private FrontendInterface $cache,
+        private PolicyProvider $policyProvider,
     ) {}
 
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
diff --git a/typo3/sysext/backend/Configuration/Services.yaml b/typo3/sysext/backend/Configuration/Services.yaml
index d6e7ca22b0b7..f2a4b230e979 100644
--- a/typo3/sysext/backend/Configuration/Services.yaml
+++ b/typo3/sysext/backend/Configuration/Services.yaml
@@ -15,15 +15,6 @@ services:
     tags:
       - { name: 'console.command', command: 'backend:user:create', description: 'Create a backend user', schedulable: false }
 
-  TYPO3\CMS\Backend\Middleware\ContentSecurityPolicyHeaders:
-    arguments:
-      $cache: '@cache.assets'
-
-  TYPO3\CMS\Backend\Backend\Avatar\Avatar:
-    public: true
-    arguments:
-      $cache: '@cache.runtime'
-
   TYPO3\CMS\Backend\Authentication\PasswordReset:
     public: true
 
diff --git a/typo3/sysext/core/Classes/Configuration/Extension/ExtLocalconfFactory.php b/typo3/sysext/core/Classes/Configuration/Extension/ExtLocalconfFactory.php
index 12ce2591033e..346282e4b982 100644
--- a/typo3/sysext/core/Classes/Configuration/Extension/ExtLocalconfFactory.php
+++ b/typo3/sysext/core/Classes/Configuration/Extension/ExtLocalconfFactory.php
@@ -17,6 +17,8 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\Configuration\Extension;
 
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -24,11 +26,13 @@ use TYPO3\CMS\Core\Package\PackageManager;
 /**
  * @internal Bootstrap related ext_localconf loading. Extensions must not use this.
  */
-final class ExtLocalconfFactory
+#[Autoconfigure(public: true)]
+final readonly class ExtLocalconfFactory
 {
     public function __construct(
-        private readonly PackageManager $packageManager,
-        private readonly PhpFrontend $codeCache,
+        private PackageManager $packageManager,
+        #[Autowire(service: 'cache.core')]
+        private PhpFrontend $codeCache,
     ) {}
 
     /**
diff --git a/typo3/sysext/core/Classes/Configuration/Extension/ExtTablesFactory.php b/typo3/sysext/core/Classes/Configuration/Extension/ExtTablesFactory.php
index f19173fe80e4..c27c5e88d026 100644
--- a/typo3/sysext/core/Classes/Configuration/Extension/ExtTablesFactory.php
+++ b/typo3/sysext/core/Classes/Configuration/Extension/ExtTablesFactory.php
@@ -17,6 +17,8 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\Configuration\Extension;
 
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Package\Cache\PackageDependentCacheIdentifier;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -24,11 +26,13 @@ use TYPO3\CMS\Core\Package\PackageManager;
 /**
  * @internal Bootstrap related ext_tables loading. Extensions must not use this.
  */
-final class ExtTablesFactory
+#[Autoconfigure(public: true)]
+final readonly class ExtTablesFactory
 {
     public function __construct(
-        private readonly PackageManager $packageManager,
-        private readonly PhpFrontend $codeCache,
+        private PackageManager $packageManager,
+        #[Autowire(service: 'cache.core')]
+        private PhpFrontend $codeCache,
     ) {}
 
     /**
diff --git a/typo3/sysext/core/Classes/Configuration/Tca/TcaFactory.php b/typo3/sysext/core/Classes/Configuration/Tca/TcaFactory.php
index 7b96f160854a..904755cf91ea 100644
--- a/typo3/sysext/core/Classes/Configuration/Tca/TcaFactory.php
+++ b/typo3/sysext/core/Classes/Configuration/Tca/TcaFactory.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Core\Configuration\Tca;
 
 use Psr\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use Symfony\Component\Finder\Finder;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent;
@@ -30,12 +32,14 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * @internal Bootstrap related base TCA loading. Extensions must not use this.
  */
-final class TcaFactory
+#[Autoconfigure(public: true)]
+final readonly class TcaFactory
 {
     public function __construct(
-        private readonly PackageManager $packageManager,
-        private readonly EventDispatcherInterface $eventDispatcher,
-        private readonly PhpFrontend $codeCache,
+        private PackageManager $packageManager,
+        private EventDispatcherInterface $eventDispatcher,
+        #[Autowire(service: 'cache.core')]
+        private PhpFrontend $codeCache,
     ) {}
 
     /**
diff --git a/typo3/sysext/core/Classes/DataHandling/SoftReference/SoftReferenceParserFactory.php b/typo3/sysext/core/Classes/DataHandling/SoftReference/SoftReferenceParserFactory.php
index f9dd4d9b1efb..6bcf5bc96b6e 100644
--- a/typo3/sysext/core/Classes/DataHandling/SoftReference/SoftReferenceParserFactory.php
+++ b/typo3/sysext/core/Classes/DataHandling/SoftReference/SoftReferenceParserFactory.php
@@ -18,23 +18,21 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Core\DataHandling\SoftReference;
 
 use Psr\Log\LoggerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
-/**
- * Factory class for soft reference parsers
- */
+#[Autoconfigure(public: true)]
 class SoftReferenceParserFactory
 {
     protected array $softReferenceParsers = [];
-    protected FrontendInterface $runtimeCache;
-    protected LoggerInterface $logger;
 
-    public function __construct(FrontendInterface $runtimeCache, LoggerInterface $logger)
-    {
-        $this->runtimeCache = $runtimeCache;
-        $this->logger = $logger;
-    }
+    public function __construct(
+        #[Autowire(service: 'cache.runtime')]
+        protected readonly FrontendInterface $runtimeCache,
+        protected readonly LoggerInterface $logger,
+    ) {}
 
     /**
      * Adds a parser via DI.
@@ -116,9 +114,6 @@ class SoftReferenceParserFactory
      *     tags:
      *       - name: softreference.parser
      *         parserKey: userdefined
-     *
-     *
-     * @param string $softReferenceParserKey
      */
     public function getSoftReferenceParser(string $softReferenceParserKey): SoftReferenceParserInterface
     {
diff --git a/typo3/sysext/core/Classes/ExpressionLanguage/ProviderConfigurationLoader.php b/typo3/sysext/core/Classes/ExpressionLanguage/ProviderConfigurationLoader.php
index d7a32afedcb9..06e89a81c993 100644
--- a/typo3/sysext/core/Classes/ExpressionLanguage/ProviderConfigurationLoader.php
+++ b/typo3/sysext/core/Classes/ExpressionLanguage/ProviderConfigurationLoader.php
@@ -17,6 +17,8 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\ExpressionLanguage;
 
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Attribute\AsEventListener;
 use TYPO3\CMS\Core\Cache\Event\CacheWarmupEvent;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
@@ -25,12 +27,15 @@ use TYPO3\CMS\Core\Package\PackageManager;
 /**
  * This class resolves the expression language provider configuration and store in a cache.
  */
-class ProviderConfigurationLoader
+#[Autoconfigure(public: true)]
+readonly class ProviderConfigurationLoader
 {
     public function __construct(
-        private readonly PackageManager $packageManager,
-        private readonly PhpFrontend $coreCache,
-        private readonly string $cacheIdentifier,
+        private PackageManager $packageManager,
+        #[Autowire(service: 'cache.core')]
+        private PhpFrontend $coreCache,
+        #[Autowire(expression: 'service("package-dependent-cache-identifier").withPrefix("ExpressionLanguageProviders").toString()')]
+        private string $cacheIdentifier,
     ) {}
 
     public function getExpressionLanguageProviders(): array
diff --git a/typo3/sysext/core/Classes/Page/ImportMapFactory.php b/typo3/sysext/core/Classes/Page/ImportMapFactory.php
index 7a16d696f614..fe96cb8604b1 100644
--- a/typo3/sysext/core/Classes/Page/ImportMapFactory.php
+++ b/typo3/sysext/core/Classes/Page/ImportMapFactory.php
@@ -18,18 +18,23 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Core\Page;
 
 use Psr\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Crypto\HashService;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\SingletonInterface;
 
+#[Autoconfigure(public: true)]
 class ImportMapFactory implements SingletonInterface
 {
     public function __construct(
         private readonly HashService $hashService,
         private readonly PackageManager $packageManager,
+        #[Autowire(service: 'cache.assets')]
         private readonly FrontendInterface $assetsCache,
         private readonly EventDispatcherInterface $eventDispatcher,
+        #[Autowire(expression: 'service("package-dependent-cache-identifier").withPrefix("ImportMap").toString()')]
         private readonly string $cacheIdentifier,
     ) {}
 
diff --git a/typo3/sysext/core/Classes/Page/PageRenderer.php b/typo3/sysext/core/Classes/Page/PageRenderer.php
index cd34638667bd..cf15801bcd10 100644
--- a/typo3/sysext/core/Classes/Page/PageRenderer.php
+++ b/typo3/sysext/core/Classes/Page/PageRenderer.php
@@ -19,6 +19,7 @@ use Psr\Http\Message\ResponseFactoryInterface;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Message\StreamFactoryInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Backend\Routing\Router;
 use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
@@ -122,6 +123,7 @@ class PageRenderer implements SingletonInterface
     protected bool $applyNonceHint = false;
 
     public function __construct(
+        #[Autowire(service: 'cache.assets')]
         protected readonly FrontendInterface $assetsCache,
         protected readonly MarkerBasedTemplateService $templateService,
         protected readonly MetaTagManagerRegistry $metaTagRegistry,
@@ -133,7 +135,6 @@ class PageRenderer implements SingletonInterface
         protected readonly StreamFactoryInterface $streamFactory,
     ) {
         $this->reset();
-
         $this->setMetaTag('name', 'generator', 'TYPO3 CMS');
     }
 
diff --git a/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php b/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php
index 30b3cf8ce151..3805ae165895 100644
--- a/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php
+++ b/typo3/sysext/core/Classes/Service/MarkerBasedTemplateService.php
@@ -15,6 +15,8 @@
 
 namespace TYPO3\CMS\Core\Service;
 
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -23,11 +25,14 @@ use TYPO3\CMS\Core\Utility\MathUtility;
  * Helper functionality for subparts and marker substitution
  * ###MYMARKER###
  */
-class MarkerBasedTemplateService
+#[Autoconfigure(public: true)]
+readonly class MarkerBasedTemplateService
 {
     public function __construct(
-        protected readonly FrontendInterface $hashCache,
-        protected readonly FrontendInterface $runtimeCache,
+        #[Autowire(service: 'cache.assets')]
+        protected FrontendInterface $hashCache,
+        #[Autowire(service: 'cache.runtime')]
+        protected FrontendInterface $runtimeCache,
     ) {}
 
     /**
diff --git a/typo3/sysext/core/Classes/TypoScript/PageTsConfigFactory.php b/typo3/sysext/core/Classes/TypoScript/PageTsConfigFactory.php
index 3c482198af86..04ad2a0089df 100644
--- a/typo3/sysext/core/Classes/TypoScript/PageTsConfigFactory.php
+++ b/typo3/sysext/core/Classes/TypoScript/PageTsConfigFactory.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Core\TypoScript;
 
 use Psr\Container\ContainerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Site\Entity\Site;
@@ -40,13 +42,15 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * @internal Internal for now until API stabilized. Use BackendUtility::getPagesTSconfig().
  */
-final class PageTsConfigFactory
+#[Autoconfigure(public: true)]
+final readonly class PageTsConfigFactory
 {
     public function __construct(
-        private readonly ContainerInterface $container,
-        private readonly TokenizerInterface $tokenizer,
-        private readonly TsConfigTreeBuilder $tsConfigTreeBuilder,
-        private readonly PhpFrontend $cache,
+        private ContainerInterface $container,
+        private TokenizerInterface $tokenizer,
+        private TsConfigTreeBuilder $tsConfigTreeBuilder,
+        #[Autowire(service: 'cache.typoscript')]
+        private PhpFrontend $cache,
     ) {}
 
     public function create(
diff --git a/typo3/sysext/core/Classes/TypoScript/UserTsConfigFactory.php b/typo3/sysext/core/Classes/TypoScript/UserTsConfigFactory.php
index 07a8880a6d06..bc92cc0c350e 100644
--- a/typo3/sysext/core/Classes/TypoScript/UserTsConfigFactory.php
+++ b/typo3/sysext/core/Classes/TypoScript/UserTsConfigFactory.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Core\TypoScript;
 
 use Psr\Container\ContainerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\TypoScript\IncludeTree\Traverser\ConditionVerdictAwareIncludeTreeTraverser;
@@ -34,13 +36,15 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  *
  * @internal Internal for now until API stabilized. Use backendUser->getTSConfig().
  */
-final class UserTsConfigFactory
+#[Autoconfigure(public: true)]
+final readonly class UserTsConfigFactory
 {
     public function __construct(
-        private readonly ContainerInterface $container,
-        private readonly TokenizerInterface $tokenizer,
-        private readonly TsConfigTreeBuilder $tsConfigTreeBuilder,
-        private readonly PhpFrontend $cache,
+        private ContainerInterface $container,
+        private TokenizerInterface $tokenizer,
+        private TsConfigTreeBuilder $tsConfigTreeBuilder,
+        #[Autowire(service: 'cache.typoscript')]
+        private PhpFrontend $cache,
     ) {}
 
     public function create(BackendUserAuthentication $backendUser): UserTsConfig
diff --git a/typo3/sysext/core/Configuration/Services.yaml b/typo3/sysext/core/Configuration/Services.yaml
index 9a4932dbbda7..4ce9b6228c43 100644
--- a/typo3/sysext/core/Configuration/Services.yaml
+++ b/typo3/sysext/core/Configuration/Services.yaml
@@ -7,8 +7,8 @@ services:
   TYPO3\CMS\Core\:
     resource: '../Classes/*'
     # glob for services that have been previously available as
-    # container entries and have been removed in the mean time
-    # (e.g. because factories are to be used instead)
+    # container entries and have been removed in the meantime,
+    # e.g. because factories are to be used instead.
     exclude: '../Classes/{Localization/LanguageService.php}'
 
   TYPO3\CMS\Core\DependencyInjection\EnvVarProcessor:
@@ -182,56 +182,20 @@ services:
       - name: softreference.parser
         parserKey: url
 
-  TYPO3\CMS\Core\DataHandling\SoftReference\SoftReferenceParserFactory:
-    public: true
-    arguments:
-      $runtimeCache: '@cache.runtime'
-
-  TYPO3\CMS\Core\Configuration\Extension\ExtLocalconfFactory:
-    public: true
-    arguments:
-      $codeCache: '@cache.core'
-
-  TYPO3\CMS\Core\Configuration\Extension\ExtTablesFactory:
-    public: true
-    arguments:
-      $codeCache: '@cache.core'
-
-  TYPO3\CMS\Core\Configuration\Tca\TcaFactory:
-    public: true
-    arguments:
-      $codeCache: '@cache.core'
-
   TYPO3\CMS\Core\ExpressionLanguage\DefaultProvider:
     public: true
 
-  TYPO3\CMS\Core\ExpressionLanguage\ProviderConfigurationLoader:
-    public: true
-    arguments:
-      $coreCache: '@cache.core'
-      $cacheIdentifier: '@=service("TYPO3\\CMS\\Core\\Package\\Cache\\PackageDependentCacheIdentifier").withPrefix("ExpressionLanguageProviders").toString()'
-
   TYPO3\CMS\Core\Locking\ResourceMutex:
     public: true
 
   TYPO3\CMS\Core\Page\PageLayoutResolver:
     public: true
 
-  TYPO3\CMS\Core\Page\PageRenderer:
-    arguments:
-      $assetsCache: '@cache.assets'
-
   TYPO3\CMS\Core\Page\AssetRenderer:
     public: true
     arguments:
       $eventDispatcher: '@Psr\EventDispatcher\EventDispatcherInterface'
 
-  TYPO3\CMS\Core\Page\ImportMapFactory:
-    public: true
-    arguments:
-      $assetsCache: '@cache.assets'
-      $cacheIdentifier: '@=service("TYPO3\\CMS\\Core\\Package\\Cache\\PackageDependentCacheIdentifier").withPrefix("ImportMap").toString()'
-
   TYPO3\CMS\Core\Resource\FileRepository:
     public: true
 
@@ -253,12 +217,6 @@ services:
   TYPO3\CMS\Core\Domain\Access\RecordAccessVoter:
     public: true
 
-  TYPO3\CMS\Core\Service\MarkerBasedTemplateService:
-    public: true
-    arguments:
-      $hashCache: '@cache.assets'
-      $runtimeCache: '@cache.runtime'
-
   TYPO3\CMS\Core\TypoScript\AST\AstBuilderInterface:
     alias: TYPO3\CMS\Core\TypoScript\AST\AstBuilder
 
@@ -305,16 +263,6 @@ services:
   TYPO3\CMS\Core\TypoScript\Tokenizer\TokenizerInterface:
     alias: TYPO3\CMS\Core\TypoScript\Tokenizer\LossyTokenizer
 
-  TYPO3\CMS\Core\TypoScript\PageTsConfigFactory:
-    public: true
-    arguments:
-      $cache: '@cache.typoscript'
-
-  TYPO3\CMS\Core\TypoScript\UserTsConfigFactory:
-    public: true
-    arguments:
-      $cache: '@cache.typoscript'
-
   TYPO3\CMS\Core\Utility\DiffUtility:
     shared: false
 
@@ -457,8 +405,8 @@ services:
     alias: GuzzleHttp\Client
     public: true
   Symfony\Contracts\EventDispatcher\EventDispatcherInterface:
-      alias: TYPO3\CMS\Core\Adapter\EventDispatcherAdapter
-      public: true
+    alias: TYPO3\CMS\Core\Adapter\EventDispatcherAdapter
+    public: true
   TYPO3\CMS\Core\Mail\MailerInterface:
     alias: TYPO3\CMS\Core\Mail\Mailer
     public: true
diff --git a/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php b/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php
index c635496a746e..b02b57b00def 100644
--- a/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php
+++ b/typo3/sysext/dashboard/Classes/Widgets/RssWidget.php
@@ -18,8 +18,9 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Dashboard\Widgets;
 
 use Psr\Http\Message\ServerRequestInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Backend\View\BackendViewFactory;
-use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface as Cache;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -46,7 +47,8 @@ class RssWidget implements WidgetInterface, RequestAwareWidgetInterface
 
     public function __construct(
         private readonly WidgetConfigurationInterface $configuration,
-        private readonly Cache $cache,
+        #[Autowire(service: 'cache.dashboard.rss')]
+        private readonly FrontendInterface $cache,
         private readonly BackendViewFactory $backendViewFactory,
         private readonly ?ButtonProviderInterface $buttonProvider = null,
         array $options = [],
diff --git a/typo3/sysext/dashboard/Configuration/Backend/DashboardWidgets.yaml b/typo3/sysext/dashboard/Configuration/Backend/DashboardWidgets.yaml
index 4b2bb336fbbc..ec77f4b93430 100644
--- a/typo3/sysext/dashboard/Configuration/Backend/DashboardWidgets.yaml
+++ b/typo3/sysext/dashboard/Configuration/Backend/DashboardWidgets.yaml
@@ -58,7 +58,6 @@ services:
   dashboard.widget.t3news:
     class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
     arguments:
-      $cache: '@cache.dashboard.rss'
       $buttonProvider: '@dashboard.buttons.t3news'
       $options:
         feedUrl: 'https://typo3.org/rss'
@@ -162,7 +161,6 @@ services:
   dashboard.widget.t3securityAdvisories:
     class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
     arguments:
-      $cache: '@cache.dashboard.rss'
       $buttonProvider: '@dashboard.buttons.t3securityAdvisories'
       $options:
         feedUrl: 'https://typo3.org/rss-security'
diff --git a/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst b/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst
index 0d2c81cbd93b..0c1970a4687e 100644
--- a/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst
+++ b/typo3/sysext/dashboard/Documentation/Configuration/WidgetRegistration.rst
@@ -53,7 +53,6 @@ the following service registration can be used inside of :file:`Configuration/Se
        class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
        arguments:
          $buttonProvider: '@dashboard.buttons.t3news'
-         $cache: '@cache.dashboard.rss'
          $options:
            feedUrl: 'https://www.typo3.org/rss'
        tags:
@@ -207,7 +206,6 @@ An example to split up all Widget related configuration would look like:
        class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
        arguments:
          $buttonProvider: '@dashboard.buttons.t3news'
-         $cache: '@cache.dashboard.rss'
          $options:
            feedUrl: 'https://www.typo3.org/rss'
        tags:
diff --git a/typo3/sysext/dashboard/Documentation/Developer/MakeRefreshable.rst b/typo3/sysext/dashboard/Documentation/Developer/MakeRefreshable.rst
index dab6ffde96e6..6c3c64365241 100644
--- a/typo3/sysext/dashboard/Documentation/Developer/MakeRefreshable.rst
+++ b/typo3/sysext/dashboard/Documentation/Developer/MakeRefreshable.rst
@@ -21,7 +21,6 @@ registration. Below is an example of a RSS widget with the refresh option enable
    dashboard.widget.myOwnRSSWidget:
      class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
      arguments:
-       $cache: '@cache.dashboard.rss'
        $options:
          rssFile: 'https://typo3.org/rss'
          lifeTime: 43200
diff --git a/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst b/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst
index 6262ecf667f0..09dbd3d2909c 100644
--- a/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst
+++ b/typo3/sysext/dashboard/Documentation/Widgets/RssWidget.rst
@@ -36,7 +36,6 @@ Example
      dashboard.widget.t3news:
        class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
        arguments:
-         $cache: '@cache.dashboard.rss'
          $buttonProvider: '@dashboard.buttons.t3news'
          $options:
            feedUrl: 'https://www.typo3.org/rss'
@@ -86,8 +85,3 @@ Dependencies
    This button should be provided by a ButtonProvider that implements the interface :php:`ButtonProviderInterface`.
 
    See :ref:`adding-buttons` for further info and configuration options.
-
-.. option:: $cache
-
-   Used to cache fetched RSS items.
-   This should not be changed.
diff --git a/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php b/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
index be00ce11c449..71d2dfad31ba 100644
--- a/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
+++ b/typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Extbase\Configuration;
 
 use Psr\Http\Message\ServerRequestInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
@@ -65,6 +67,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
  *
  * @internal only to be used within Extbase, not part of TYPO3 Core API.
  */
+#[Autoconfigure(public: true)]
 class BackendConfigurationManager implements SingletonInterface
 {
     /**
@@ -95,7 +98,9 @@ class BackendConfigurationManager implements SingletonInterface
 
     public function __construct(
         private readonly TypoScriptService $typoScriptService,
+        #[Autowire(service: 'cache.typoscript')]
         private readonly PhpFrontend $typoScriptCache,
+        #[Autowire(service: 'cache.runtime')]
         private readonly FrontendInterface $runtimeCache,
         private readonly SysTemplateRepository $sysTemplateRepository,
         private readonly SiteFinder $siteFinder,
diff --git a/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php b/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
index 409038b0b71b..ceeb646ba630 100644
--- a/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
+++ b/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
@@ -17,26 +17,22 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Extbase\Persistence;
 
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
 use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
 
-final class ClassesConfigurationFactory
+final readonly class ClassesConfigurationFactory
 {
-    private FrontendInterface $cache;
-
-    private PackageManager $packageManager;
-
-    private string $cacheIdentifier;
-
-    public function __construct(FrontendInterface $cache, PackageManager $packageManager, string $cacheIdentifier)
-    {
-        $this->cache = $cache;
-        $this->packageManager = $packageManager;
-        $this->cacheIdentifier = $cacheIdentifier;
-    }
+    public function __construct(
+        #[Autowire(service: 'cache.extbase')]
+        private FrontendInterface $cache,
+        private PackageManager $packageManager,
+        #[Autowire(expression: 'service("package-dependent-cache-identifier").withPrefix("PersistenceClasses").toString()')]
+        private string $cacheIdentifier,
+    ) {}
 
     public function createClassesConfiguration(): ClassesConfiguration
     {
diff --git a/typo3/sysext/extbase/Configuration/Services.yaml b/typo3/sysext/extbase/Configuration/Services.yaml
index ed4bcaa462bc..09077e2c826f 100644
--- a/typo3/sysext/extbase/Configuration/Services.yaml
+++ b/typo3/sysext/extbase/Configuration/Services.yaml
@@ -11,12 +11,6 @@ services:
     public: true
     shared: false
 
-  TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager:
-    public: true
-    arguments:
-      $typoScriptCache: '@cache.typoscript'
-      $runtimeCache: '@cache.runtime'
-
   # formerly in EXT:extbase/ext_localconf.php
   TYPO3\CMS\Extbase\Persistence\QueryInterface:
     alias: TYPO3\CMS\Extbase\Persistence\Generic\Query
@@ -75,11 +69,6 @@ services:
   TYPO3\CMS\Extbase\Persistence\ClassesConfiguration:
     factory: ['@TYPO3\CMS\Extbase\Persistence\ClassesConfigurationFactory', 'createClassesConfiguration']
 
-  TYPO3\CMS\Extbase\Persistence\ClassesConfigurationFactory:
-    arguments:
-      $cache: '@cache.extbase'
-      $cacheIdentifier: '@=service("TYPO3\\CMS\\Core\\Package\\Cache\\PackageDependentCacheIdentifier").withPrefix("PersistenceClasses").toString()'
-
   TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory:
     arguments:
       $baseCacheIdentifier: '@=service("TYPO3\\CMS\\Core\\Package\\Cache\\PackageDependentCacheIdentifier").toString()'
diff --git a/typo3/sysext/form/Classes/Service/TranslationService.php b/typo3/sysext/form/Classes/Service/TranslationService.php
index 3a98cd962d63..28fdac63bc2c 100644
--- a/typo3/sysext/form/Classes/Service/TranslationService.php
+++ b/typo3/sysext/form/Classes/Service/TranslationService.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Form\Service;
 
 use Psr\Http\Message\ServerRequestInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Http\ApplicationType;
 use TYPO3\CMS\Core\Localization\LanguageService;
@@ -41,6 +43,7 @@ use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
  * Scope: frontend / backend
  * @internal
  */
+#[Autoconfigure(public: true)]
 class TranslationService implements SingletonInterface
 {
     /**
@@ -53,6 +56,7 @@ class TranslationService implements SingletonInterface
     public function __construct(
         protected readonly ConfigurationManagerInterface $configurationManager,
         protected readonly LanguageServiceFactory $languageServiceFactory,
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $runtimeCache,
         protected readonly Locales $locales
     ) {}
diff --git a/typo3/sysext/form/Configuration/Services.yaml b/typo3/sysext/form/Configuration/Services.yaml
index be1eda811028..0277b54f1ac8 100644
--- a/typo3/sysext/form/Configuration/Services.yaml
+++ b/typo3/sysext/form/Configuration/Services.yaml
@@ -19,11 +19,6 @@ services:
     alias: TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
     public: true
 
-  TYPO3\CMS\Form\Service\TranslationService:
-    public: true
-    arguments:
-      $runtimeCache: '@cache.runtime'
-
   TYPO3\CMS\Form\Domain\Factory\ArrayFormFactory:
     public: true
     shared: false
diff --git a/typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php b/typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php
index 06e830a2a6da..c79b7f3afba6 100644
--- a/typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php
+++ b/typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php
@@ -18,6 +18,8 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Frontend\Cache;
 
 use Psr\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Database\Connection;
@@ -35,11 +37,13 @@ use TYPO3\CMS\Frontend\Event\ModifyCacheLifetimeForPageEvent;
  *
  * @internal This class is not part of the TYPO3 Core API
  */
+#[Autoconfigure(public: true)]
 class CacheLifetimeCalculator
 {
     protected int $defaultCacheTimeout = 86400;
 
     public function __construct(
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $runtimeCache,
         protected readonly EventDispatcherInterface $eventDispatcher,
         protected readonly ConnectionPool $connectionPool
diff --git a/typo3/sysext/frontend/Classes/Middleware/ContentSecurityPolicyHeaders.php b/typo3/sysext/frontend/Classes/Middleware/ContentSecurityPolicyHeaders.php
index ccd7c51059a1..85b96326b9c4 100644
--- a/typo3/sysext/frontend/Classes/Middleware/ContentSecurityPolicyHeaders.php
+++ b/typo3/sysext/frontend/Classes/Middleware/ContentSecurityPolicyHeaders.php
@@ -22,6 +22,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface;
 use Psr\Log\LoggerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Configuration\Features;
 use TYPO3\CMS\Core\Core\RequestId;
@@ -34,14 +35,15 @@ use TYPO3\CMS\Core\Security\ContentSecurityPolicy\UriValue;
  *
  * @internal
  */
-final class ContentSecurityPolicyHeaders implements MiddlewareInterface
+final readonly class ContentSecurityPolicyHeaders implements MiddlewareInterface
 {
     public function __construct(
-        private readonly Features $features,
-        private readonly RequestId $requestId,
-        private readonly LoggerInterface $logger,
-        private readonly FrontendInterface $cache,
-        private readonly PolicyProvider $policyProvider,
+        private Features $features,
+        private RequestId $requestId,
+        private LoggerInterface $logger,
+        #[Autowire(service: 'cache.assets')]
+        private FrontendInterface $cache,
+        private PolicyProvider $policyProvider,
     ) {}
 
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
diff --git a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php
index 636de88afdfc..602ad672a495 100644
--- a/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php
+++ b/typo3/sysext/frontend/Classes/Middleware/PrepareTypoScriptFrontendRendering.php
@@ -23,6 +23,7 @@ use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Server\MiddlewareInterface;
 use Psr\Http\Server\RequestHandlerInterface;
 use Psr\Log\LoggerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Context\Context;
@@ -49,7 +50,9 @@ final readonly class PrepareTypoScriptFrontendRendering implements MiddlewareInt
     public function __construct(
         private EventDispatcherInterface $eventDispatcher,
         private FrontendTypoScriptFactory $frontendTypoScriptFactory,
+        #[Autowire(service: 'cache.typoscript')]
         private PhpFrontend $typoScriptCache,
+        #[Autowire(service: 'cache.pages')]
         private FrontendInterface $pageCache,
         private ResourceMutex $lock,
         private Context $context,
diff --git a/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php b/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php
index 2170e268d576..a174eaaa89b1 100644
--- a/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php
+++ b/typo3/sysext/frontend/Classes/Typolink/LinkFactory.php
@@ -20,6 +20,8 @@ namespace TYPO3\CMS\Frontend\Typolink;
 use Psr\EventDispatcher\EventDispatcherInterface;
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
+use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
 use TYPO3\CMS\Core\LinkHandling\LinkService;
@@ -36,6 +38,7 @@ use TYPO3\CMS\Frontend\Event\AfterLinkIsGeneratedEvent;
  * Main class for generating any kind of frontend links.
  * Contains all logic for the infamous typolink() functionality.
  */
+#[Autoconfigure(public: true)]
 class LinkFactory implements LoggerAwareInterface
 {
     use DefaultJavaScriptAssetTrait;
@@ -45,6 +48,7 @@ class LinkFactory implements LoggerAwareInterface
         protected readonly LinkService $linkService,
         protected readonly EventDispatcherInterface $eventDispatcher,
         protected readonly TypoLinkCodecService $typoLinkCodecService,
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $runtimeCache,
         protected readonly SiteFinder $siteFinder,
     ) {}
diff --git a/typo3/sysext/frontend/Configuration/Services.yaml b/typo3/sysext/frontend/Configuration/Services.yaml
index ca7c6b0120ff..ec363a55bfff 100644
--- a/typo3/sysext/frontend/Configuration/Services.yaml
+++ b/typo3/sysext/frontend/Configuration/Services.yaml
@@ -11,15 +11,6 @@ services:
     # (e.g. because factories are to be used instead)
     exclude: '../Classes/{Frontend/Controller/TypoScriptFrontendController.php}'
 
-  TYPO3\CMS\Frontend\Middleware\ContentSecurityPolicyHeaders:
-    arguments:
-      $cache: '@cache.assets'
-
-  TYPO3\CMS\Frontend\Middleware\PrepareTypoScriptFrontendRendering:
-    arguments:
-      $pageCache: '@cache.pages'
-      $typoScriptCache: '@cache.typoscript'
-
   TYPO3\CMS\Frontend\Controller\ShowImageController:
     public: true
 
@@ -55,11 +46,6 @@ services:
   TYPO3\CMS\Frontend\Html\HtmlWorker:
     public: true
 
-  TYPO3\CMS\Frontend\Cache\CacheLifetimeCalculator:
-    public: true
-    arguments:
-      $runtimeCache: '@cache.runtime'
-
   # Register all available content objects
   TYPO3\CMS\Frontend\ContentObject\TextContentObject:
     tags:
@@ -146,11 +132,6 @@ services:
       - name: frontend.contentobject
         identifier: 'SVG'
 
-  TYPO3\CMS\Frontend\Typolink\LinkFactory:
-    public: true
-    arguments:
-      $runtimeCache: '@cache.runtime'
-
   TYPO3\CMS\Frontend\DataProcessing\CommaSeparatedValueProcessor:
     tags:
       - { name: 'data.processor', identifier: 'comma-separated-value' }
diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
index ab15707b0ee0..6cdc6a4bfe90 100644
--- a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
+++ b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
@@ -19,6 +19,7 @@ namespace TYPO3\CMS\Recycler\Controller;
 
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Backend\Attribute\AsController;
 use TYPO3\CMS\Backend\History\RecordHistory;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
@@ -52,6 +53,7 @@ class RecyclerAjaxController
 
     public function __construct(
         protected readonly BackendViewFactory $backendViewFactory,
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $runtimeCache,
         protected readonly IconFactory $iconFactory,
         protected readonly ConnectionPool $connectionPool,
diff --git a/typo3/sysext/recycler/Configuration/Services.yaml b/typo3/sysext/recycler/Configuration/Services.yaml
index 43e771638ed3..35286932a4c1 100644
--- a/typo3/sysext/recycler/Configuration/Services.yaml
+++ b/typo3/sysext/recycler/Configuration/Services.yaml
@@ -8,7 +8,3 @@ services:
     resource: '../Classes/*'
     # Tasks require EXT:scheduler to be installed, ignore for now.
     exclude: '../Classes/Task'
-
-  TYPO3\CMS\Recycler\Controller\RecyclerAjaxController:
-    arguments:
-      $runtimeCache: '@cache.runtime'
diff --git a/typo3/sysext/redirects/Classes/Service/RedirectService.php b/typo3/sysext/redirects/Classes/Service/RedirectService.php
index bb431a4545af..d37d2ae3be72 100644
--- a/typo3/sysext/redirects/Classes/Service/RedirectService.php
+++ b/typo3/sysext/redirects/Classes/Service/RedirectService.php
@@ -21,6 +21,7 @@ use Psr\EventDispatcher\EventDispatcherInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Message\UriInterface;
 use Psr\Log\LoggerInterface;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
@@ -59,6 +60,7 @@ class RedirectService
         private readonly EventDispatcherInterface $eventDispatcher,
         private readonly PageInformationFactory $pageInformationFactory,
         private readonly FrontendTypoScriptFactory $frontendTypoScriptFactory,
+        #[Autowire(service: 'cache.typoscript')]
         private readonly PhpFrontend $typoScriptCache,
         private readonly LoggerInterface $logger,
     ) {}
diff --git a/typo3/sysext/redirects/Configuration/Services.yaml b/typo3/sysext/redirects/Configuration/Services.yaml
index ff62488ec202..0b021b02588b 100644
--- a/typo3/sysext/redirects/Configuration/Services.yaml
+++ b/typo3/sysext/redirects/Configuration/Services.yaml
@@ -24,7 +24,3 @@ services:
   TYPO3\CMS\Redirects\Configuration\CheckIntegrityConfiguration:
     arguments:
       $extensionConfiguration: '@extension.configuration.redirects'
-
-  TYPO3\CMS\Redirects\Service\RedirectService:
-    arguments:
-      $typoScriptCache: '@cache.typoscript'
diff --git a/typo3/sysext/webhooks/Classes/Repository/WebhookRepository.php b/typo3/sysext/webhooks/Classes/Repository/WebhookRepository.php
index 64cd6fae0be5..ec81f1fddf79 100644
--- a/typo3/sysext/webhooks/Classes/Repository/WebhookRepository.php
+++ b/typo3/sysext/webhooks/Classes/Repository/WebhookRepository.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Webhooks\Repository;
 
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -38,6 +39,7 @@ class WebhookRepository
 
     public function __construct(
         protected readonly ConnectionPool $connectionPool,
+        #[Autowire(service: 'cache.runtime')]
         protected readonly FrontendInterface $runtimeCache,
     ) {}
 
diff --git a/typo3/sysext/webhooks/Configuration/Services.yaml b/typo3/sysext/webhooks/Configuration/Services.yaml
index 63e24fdab59b..a9258a1f5b8b 100644
--- a/typo3/sysext/webhooks/Configuration/Services.yaml
+++ b/typo3/sysext/webhooks/Configuration/Services.yaml
@@ -17,10 +17,5 @@ services:
   TYPO3\CMS\Webhooks\Listener\MessageListener:
     public: true
 
-  TYPO3\CMS\Webhooks\Repository\WebhookRepository:
-    public: true # Required in test context
-    arguments:
-      $runtimeCache: '@cache.runtime'
-
   TYPO3\CMS\Webhooks\Tca\ItemsProcFunc\WebhookTypesItemsProcFunc:
     public: true
-- 
GitLab