Feature #89054
closedProvide cache frontends via dependency injection
100%
Description
Instead of injecting the CacheManager, a cache frontend should be injectable directly to a class.
TYPO3 v9 and before:
class MyClass
{
/**
* @var TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
*/
private $cache;
public function __construct()
{
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$this->cache = $cacheManager->getCache('my_cache');
}
}
This code should become:
class MyClass
{
/**
* @var TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
*/
private $cache;
public function __construct(FrontendInterface $cache)
{
$this->cache = $cache;
}
}
Since the cache frontends are not added to the service container, the injection has to be configured manually or the CacheManager has to be inejcted.
This feature suggest to add a service for each cache configuration and name it "cache.[NAME OF CONFIGURATION]" to make it available within the service container.
This will allow to configure the service above as follows:
MyClass:
arguments:
$cache: '@cache.my_cache'
Updated by Gerrit Code Review about 5 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61588
Updated by Gerrit Code Review about 5 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61588
Updated by Markus Poerschke about 5 years ago
- Assignee set to Markus Poerschke
- % Done changed from 0 to 80
Changes in documentation can be found in this Pull Request on GitHub: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/574
Updated by Gerrit Code Review about 5 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61588
Updated by Gerrit Code Review about 5 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61588
Updated by Gerrit Code Review about 5 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61588
Updated by Anonymous about 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 80 to 100
Applied in changeset b7f6cba3c64cdd768198453f5165e20efdf991e5.