TYPO3 headerNoCache

问题描述 投票:0回答:1

我的 T3 分机中有以下行

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['headerNoCache']['XY'] = \Namespace\Folder\Hooks\Class::class.'->headerNoCache ';

这不再适用于 TYPO3 版本 12。

https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-96968-PSR-14EventForAvoidLoadingFrontendPagesFromCache.html

如果没有 Service.yaml 中的条目,如何在 TYPO3 中执行此操作?我必须建立这样的东西:

public function __invoke(ShouldUseCachedPageDataIfAvailableEvent | ModifyUrlForCanonicalTagEvent $event): void
  {
    $href = $event->getUrl();
    $this->generateCanonical($href);
    $event->setUrl($href);



      $noCache = $event->getRequest()->getQueryParams();
      if ($this->canonicalActive($noCache) &&
          (    $this->canonicalForKurs($noCache)
              || $this->canonicalForDozent($noCache)
              || $this->canonicalForAussenstelle($noCache)
              || $this->canonicalForHaus($noCache)
              || $this->canonicalForRaum($noCache)
          )) {

          $event->shouldUseCachedPageData(false);
      }
  }

但是它说

Call to undefined method TYPO3\CMS\Seo\Event\ModifyUrlForCanonicalTagEvent::shouldUseCachedPageData()

typo3 extbase
1个回答
0
投票

您允许在此处调用两个不同的事件(ShouldUseCachedPageDataIfAvailableEvent | ModifyUrlForCanonicalTagEvent)。

调用方法时需要先检查当前事件的类型,因为每个事件的方法都不同。

最好为此创建两个不同的事件侦听器,而不是组合一个。

© www.soinside.com 2019 - 2024. All rights reserved.