‪TYPO3CMS  ‪main
ProcessFileListActionsEventListener.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 
29 {
30  protected const ‪DISABLED_ACTIONS = ['edit', 'view', 'replace', 'rename', 'download'];
31 
32  #[AsEventListener('form-framework/form-definition-files')]
33  public function ‪__invoke(‪ProcessFileListActionsEvent $event): void
34  {
35  if (!$event->‪isFile()) {
36  return;
37  }
38  $fullIdentifier = $event->‪getResource()->getCombinedIdentifier();
39  if (!str_ends_with($fullIdentifier, ‪FormPersistenceManager::FORM_DEFINITION_FILE_EXTENSION)) {
40  return;
41  }
42 
43  $actionItems = $event->‪getActionItems();
44  foreach (self::DISABLED_ACTIONS as $disableIconName) {
45  if (!empty($actionItems[$disableIconName])) {
46  unset($actionItems[$disableIconName]);
47  }
48  }
49  $event->‪setActionItems($actionItems);
50  }
51 }
‪TYPO3\CMS\Core\Attribute\AsEventListener
Definition: AsEventListener.php:25
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener\__invoke
‪__invoke(ProcessFileListActionsEvent $event)
Definition: ProcessFileListActionsEventListener.php:33
‪TYPO3\CMS\Form\EventListener
Definition: DataStructureIdentifierListener.php:18
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent
Definition: ProcessFileListActionsEvent.php:27
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener\DISABLED_ACTIONS
‪const DISABLED_ACTIONS
Definition: ProcessFileListActionsEventListener.php:30
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
Definition: FormPersistenceManager.php:62
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\isFile
‪isFile()
Definition: ProcessFileListActionsEvent.php:35
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\getActionItems
‪getActionItems()
Definition: ProcessFileListActionsEvent.php:40
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\getResource
‪getResource()
Definition: ProcessFileListActionsEvent.php:30
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener
Definition: ProcessFileListActionsEventListener.php:29
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\setActionItems
‪setActionItems(array $actionItems)
Definition: ProcessFileListActionsEvent.php:45
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager\FORM_DEFINITION_FILE_EXTENSION
‪const FORM_DEFINITION_FILE_EXTENSION
Definition: FormPersistenceManager.php:63