[ 'type' => 'item', 'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:export', 'iconIdentifier' => 'actions-document-export-t3d', 'callbackAction' => 'exportT3d', ], 'importT3d' => [ 'type' => 'item', 'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang.xlf:import', 'iconIdentifier' => 'actions-document-import-t3d', 'callbackAction' => 'importT3d', ], ]; public function __construct( private readonly UriBuilder $uriBuilder, ) { parent::__construct(); } /** * Export item is added for all database records except files */ public function canHandle(): bool { return $this->table !== 'sys_file'; } /** * This needs to be lower than priority of the RecordProvider */ public function getPriority(): int { return 50; } /** * Adds import/export items to the "submenu" if available */ public function addItems(array $items): array { $this->initDisabledItems(); $localItems = $this->prepareItems($this->itemsConfiguration); if (isset($items['more']['childItems'])) { $items['more']['childItems'] = $items['more']['childItems'] + $localItems; } else { $items += $localItems; } return $items; } protected function canRender(string $itemName, string $type): bool { if (in_array($itemName, $this->disabledItems, true)) { return false; } $canRender = false; switch ($itemName) { case 'exportT3d': $canRender = $this->backendUser->isExportEnabled(); break; case 'importT3d': $canRender = $this->table === 'pages' && $this->backendUser->isImportEnabled(); break; } return $canRender; } /** * Registers custom JS module with item onclick behaviour */ protected function getAdditionalAttributes(string $itemName): array { $attributes = [ 'data-callback-module' => '@typo3/impexp/context-menu-actions', ]; // Add action url for items switch ($itemName) { case 'exportT3d': $attributes['data-action-url'] = (string)$this->uriBuilder->buildUriFromRoute('tx_impexp_export'); break; case 'importT3d': $attributes['data-action-url'] = (string)$this->uriBuilder->buildUriFromRoute('tx_impexp_import'); break; } return $attributes; } }