Created
January 28, 2026 15:46
-
-
Save a-r-m-i-n/bd83a1d5701003dbf01fb9670a996488 to your computer and use it in GitHub Desktop.
Set the "edit_record" action in TYPO3's LiveSearch in Backend to default action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Vendor\Project\EventListeners; | |
| use TYPO3\CMS\Backend\Search\Event\ModifyResultItemInLiveSearchEvent; | |
| use TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction; | |
| use TYPO3\CMS\Core\Attribute\AsEventListener; | |
| #[AsEventListener(identifier: 'ext-project/edit-record-as-default-in-live-search-event-listener')] | |
| class EditRecordAsDefaultActionInLiveSearchEventListener | |
| { | |
| public function __invoke(ModifyResultItemInLiveSearchEvent $event): void | |
| { | |
| $resultItem = $event->getResultItem(); | |
| $array = $resultItem->jsonSerialize(); | |
| /** @var ResultItemAction[] $actions */ | |
| $actions = $array['actions'] ?? []; | |
| foreach ($actions as $index => $action) { | |
| if ('edit_record' === $action->jsonSerialize()['identifier']) { | |
| array_splice($actions, $index, 1); | |
| array_unshift($actions, $action); | |
| $resultItem->setActions(...$actions); | |
| break; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment