Project

General

Profile

Actions

Bug #100911

closed

Custom MenuProcessor creates kind of singleton

Added by Philipp Schlosser over 1 year ago. Updated 5 months ago.

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.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #96005: Add aliases for DataProcessorsClosed2021-11-16

Actions
Actions

Also available in: Atom PDF