Issue Bug Closed

#102922Memory limit php error when trying to add a button with addButton() in an event listener

TimoF no-lastname-given 01/25/24, 09:44 updated 02/06/24, 11:35

Description

When I try to add a button in an event listener, I get a php memory limit error.
I am using this one: https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Events/Events/Backend/ModifyButtonBarEvent.html
This is the code. Everything is working till the line with addButton().

        $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
        $buttonBar = $event->getButtonBar();
        $button = $buttonBar
            ->makeLinkButton()
            ->setHref('#')
            ->setTitle('TEST')
            ->setIcon($iconFactory->getIcon('actions-approve', Icon::SIZE_SMALL))
            ->setShowLabelText(true)
        ;
        $buttonBar->addButton($button, ButtonBar::BUTTON_POSITION_LEFT, 1);
        $event->setButtons($buttonBar->getButtons());

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.