*/
public function link($key, $altTarget = '', $typeOverride = '')
{
+ $runtimeCache = $this->getRuntimeCache();
+ $cacheId = 'menu-generated-links-' . md5($key . $altTarget . $typeOverride . serialize($this->menuArr[$key]));
+ $runtimeCachedLink = $runtimeCache->get($cacheId);
+ if ($runtimeCachedLink !== false) {
+ return $runtimeCachedLink;
+ }
+
// Mount points:
$MP_var = $this->getMPvar($key);
$MP_params = $MP_var ? '&MP=' . rawurlencode($MP_var) : '';
} catch (\Exception $ex) {
}
if (!is_array($shortcut)) {
+ $runtimeCache->set($cacheId, []);
return [];
}
// Only setting url, not target
$list['HREF'] = (string)$LD['totalURL'] !== '' ? $LD['totalURL'] : $tsfe->baseUrl;
$list['TARGET'] = $LD['target'];
$list['onClick'] = $onClick;
+ $runtimeCache->set($cacheId, $list);
return $list;
}
*/
public function isSubMenu($uid)
{
+ $cacheId = 'menucontentobject-is-submenu-decision-' . $uid;
+ $runtimeCache = $this->getRuntimeCache();
+ $cachedDecision = $runtimeCache->get($cacheId);
+ if (isset($cachedDecision['result'])) {
+ return $cachedDecision['result'];
+ }
// Looking for a mount-pid for this UID since if that
// exists we should look for a subpages THERE and not in the input $uid;
$mount_info = $this->sys_page->getMountPointInfo($uid);
$hasSubPages = true;
break;
}
+ $runtimeCache->set($cacheId, ['result' => $hasSubPages]);
return $hasSubPages;
}
}
/**
+ * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
+ */
+ protected function getRuntimeCache()
+ {
+ return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime');
+ }
+
+ /**
* Set the parentMenuArr and key to provide the parentMenu informations to the
* subMenu, special fur IProcFunc and itemArrayProcFunc user functions.
*
*
* The TYPO3 project - inspiring people to share!
*/
+use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+use TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject;
/**
* Test case
foreach ($menuItems as $page) {
$menu[] = ['uid' => $page];
}
-
+ $runtimeCacheMock = $this->getMockBuilder(VariableFrontend::class)->setMethods(['get', 'set'])->disableOriginalConstructor()->getMock();
+ $runtimeCacheMock->expects($this->once())->method('get')->with($this->anything())->willReturn(false);
+ $runtimeCacheMock->expects($this->once())->method('set')->with($this->anything(), ['result' => $expectedResult]);
+ $this->subject = $this->getMockBuilder(AbstractMenuContentObject::class)->setMethods(['getRuntimeCache'])->getMockForAbstractClass();
+ $this->subject->expects($this->once())->method('getRuntimeCache')->willReturn($runtimeCacheMock);
$this->prepareSectionIndexTest();
$this->subject->parent_cObj = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, []);