【发布时间】:2021-08-14 17:02:41
【问题描述】:
我的 cacheManager 实例迁移到 TYPO3 10 时遇到问题。根据 TYPO3 10 文档,缓存应该通过构造函数而不是“cacheManager”实例注入。
我按照文档进行操作,yaml 配置也正确,并且在前端收到错误消息。
"Class TYPO3\CMS\Core\Cache\Frontend\Frontend does not exist. Reflection failed."
据我所知,这个类根本不存在。
这个错误有解决办法吗?
EXT:my_ext/Configuration/Services.yaml
services:
cache.my_ext:
class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
arguments: ['my_ext']
MyVendor\MyExt\Connection\Http:
arguments:
$cache: '@cache.my_ext'
EXT:my_ext/Classes/Connection/Http.php
/**
* @var FrontendInterface
*/
private $cache;
public function __construct(FrontendInterface $cache)
{
$this->cache = $cache;
}
public function initializeObject() {
$className = explode('\\', get_class($this));
$this->extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($className[1]);
}
public function getDataFromUrl($url, $cachingTags = array()) {
$cacheIdentifier = sha1($url);
$remoteData = $this->getUrl($url . "&" . time());
if (($this->cache->get($cacheIdentifier)) === false) {
$this->cache->set($cacheIdentifier, $remoteData, $cachingTags,36000);
}
return $remoteData;
}
我按照这里的文档:
【问题讨论】:
-
您能否提供更多信息?哪个文档?您在 yaml 文件中配置了什么?如果您已经知道,您所做的一切都与文档相对应并且所有配置都是正确的,那么猜测出了什么问题是很困难的。如果是这样,就不应该有错误;-)
-
我遇到了同样的问题并调查了它,关于这个
\TYPO3\CMS\Core\Cache\Frontend\Frontend类的来源。在\TYPO3\CMS\Extbase\Object\Container\Container->getImplementationClassName中,\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface类在类名末尾剥离了它的接口。因此它变成了TYPO3\CMS\Core\Cache\Frontend\Frontend...但它甚至不应该首先加载接口,而是配置的指定缓存...我也没有让它工作。我们缺少什么?你有任何进展吗?
标签: caching typo3 extbase typo3-10.x