Actions
Bug #100911
closedCustom MenuProcessor creates kind of singleton
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2023-05-23
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
If you implement a custom MenuProcessor, for every new menuProcessor you define in typoscript, the same instance will be used.
for example
page = PAGE page { 10 = FLUIDTEMPLATE 10 { dataProcessing { 10 = MyVendor\MyExtension\DataProcessing\CustomMenuProcessor 10 { special = directory special.value = 10 # should show every child page from page 10 as = menuOne } 20 = MyVendor\MyExtension\DataProcessing\CustomMenuProcessor 20 { special = directory special.value = 20 # should show every child page from page 20 as = menuTwo } } } }
In this example "menuOne" should contain every child page from page 10. "menuTwo" should container every child page from page 20 but does contain pages from 10.
Another example:
Use TS Config from above and implement a counter property in your custom MenuProcessor.
namespace MyVendor\MyExtension\DataProcessing; class CustomMenuProcessor implements \TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface { protected $counter = 0; /** * @param ContentObjectRenderer $cObj * @param array $contentObjectConfiguration * @param array $processorConfiguration * @param array $processedData * @return array */ public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData): array { $this->counter ++; \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->counter); return $processedData; } }
The example above should print 1 and 1, but does 1 and 2.
Actions