13
13
14
14
use B13 \Menus \CacheHelper ;
15
15
use B13 \Menus \Domain \Repository \MenuRepository ;
16
+ use B13 \Menus \Event \CacheIdentifierForMenuEvent ;
17
+ use Psr \EventDispatcher \EventDispatcherInterface ;
16
18
use TYPO3 \CMS \Core \Context \Context ;
17
19
use TYPO3 \CMS \Core \Context \LanguageAspect ;
18
20
use TYPO3 \CMS \Core \Context \UserAspect ;
@@ -30,12 +32,14 @@ abstract class AbstractMenuCompiler implements SingletonInterface
30
32
protected MenuRepository $ menuRepository ;
31
33
protected CacheHelper $ cache ;
32
34
protected Context $ context ;
35
+ protected EventDispatcherInterface $ eventDispatcher ;
33
36
34
- public function __construct (Context $ context , CacheHelper $ cache , MenuRepository $ menuRepository )
37
+ public function __construct (Context $ context , CacheHelper $ cache , MenuRepository $ menuRepository, EventDispatcherInterface $ eventDispatcher )
35
38
{
36
39
$ this ->context = $ context ;
37
40
$ this ->menuRepository = $ menuRepository ;
38
41
$ this ->cache = $ cache ;
42
+ $ this ->eventDispatcher = $ eventDispatcher ;
39
43
}
40
44
41
45
/**
@@ -67,6 +71,9 @@ protected function generateCacheIdentifierForMenu(string $prefix, array $configu
67
71
$ visibility = $ visibilityAspect ->includeHiddenPages () ? '-with-hidden ' : '' ;
68
72
$ root = $ this ->getCurrentSite ()->getRootPageId ();
69
73
$ identifier = $ prefix . '-root- ' . $ root . '-language- ' . $ language . '-groups- ' . md5 (implode ('_ ' , $ groupIds )) . '- ' . $ visibility . '- ' . substr (md5 (json_encode ($ configuration )), 0 , 10 );
74
+ $ event = new CacheIdentifierForMenuEvent ($ identifier );
75
+ $ this ->eventDispatcher ->dispatch ($ event );
76
+ $ identifier = $ event ->getIdentifier ();
70
77
return $ identifier ;
71
78
}
72
79
0 commit comments