‪TYPO3CMS  11.5
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 
22 
28 {
29  protected const ‪DISABLED_ACTIONS = ['edit', 'view', 'replace', 'rename', 'download'];
30 
31  public function ‪__invoke(‪ProcessFileListActionsEvent $event): void
32  {
33  if (!$event->‪isFile()) {
34  return;
35  }
36  $fullIdentifier = $event->‪getResource()->getCombinedIdentifier();
37  if (!str_ends_with($fullIdentifier, ‪FormPersistenceManager::FORM_DEFINITION_FILE_EXTENSION)) {
38  return;
39  }
40 
41  $actionItems = $event->‪getActionItems();
42  foreach (self::DISABLED_ACTIONS as $disableIconName) {
43  if (!empty($actionItems[$disableIconName])) {
44  $actionItems[$disableIconName] = null;
45  }
46  }
47  $event->‪setActionItems($actionItems);
48  }
49 }
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener\__invoke
‪__invoke(ProcessFileListActionsEvent $event)
Definition: ProcessFileListActionsEventListener.php:31
‪TYPO3\CMS\Form\EventListener
Definition: ProcessFileListActionsEventListener.php:18
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent
Definition: ProcessFileListActionsEvent.php:27
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener\DISABLED_ACTIONS
‪const DISABLED_ACTIONS
Definition: ProcessFileListActionsEventListener.php:29
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
Definition: FormPersistenceManager.php:54
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\isFile
‪isFile()
Definition: ProcessFileListActionsEvent.php:42
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\getActionItems
‪getActionItems()
Definition: ProcessFileListActionsEvent.php:47
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\getResource
‪getResource()
Definition: ProcessFileListActionsEvent.php:37
‪TYPO3\CMS\Form\EventListener\ProcessFileListActionsEventListener
Definition: ProcessFileListActionsEventListener.php:28
‪TYPO3\CMS\Filelist\Event\ProcessFileListActionsEvent\setActionItems
‪setActionItems(array $actionItems)
Definition: ProcessFileListActionsEvent.php:52
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager\FORM_DEFINITION_FILE_EXTENSION
‪const FORM_DEFINITION_FILE_EXTENSION
Definition: FormPersistenceManager.php:55