TYPO3 Extbase individual code on backend-deletion of an object

前端 未结 2 1778
春和景丽
春和景丽 2021-01-14 08:03

I would like to execute some individual code when one of my Extbase domain objects is deleted from the list view in TYPO3 backend.

Thought that it could / would work

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 08:30

    In addition to biesiors answer I want to point out, that there is also a signalSlot for this. So you can rather register on that signal than hooking into tcemain.

    in your ext_localconf.php put:

    $signalSlotDispatcher =
                \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
    $signalSlotDispatcher->connect(
        'TYPO3\CMS\Extbase\Persistence\Generic\Backend',
        'afterRemoveObject',
        'Vendor\MxExtension\Slots\MyAfterRemoveObjectSlot',
        'myAfterRemoveObjectMethod'
    );
    

    So in your Slot you have this PHP file:

    namespace Vendor\MxExtension\Slots;
    class MyAfterRemoveObjectSlot {
        public function myAfterRemoveObjectMethod($object) {
             // do something
        }
    }
    

    Note thet $object will be the $object that was just removed from the DB.

    For more information, see https://usetypo3.com/signals-and-hooks-in-typo3.html

提交回复
热议问题