‪TYPO3CMS  ‪main
FormFileProvider.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 
18 namespace ‪TYPO3\CMS\Form\Hooks;
19 
22 
28 {
32  protected ‪$itemsConfiguration = [];
33 
37  public function ‪getPriority(): int
38  {
39  return 0;
40  }
41 
42  public function ‪canHandle(): bool
43  {
44  return parent::canHandle()
45  && str_ends_with($this->identifier, ‪FormPersistenceManager::FORM_DEFINITION_FILE_EXTENSION);
46  }
47 
48  public function ‪addItems(array $items): array
49  {
50  $this->‪initialize();
51  return $this->‪purgeItems($items);
52  }
53 
65  protected function ‪purgeItems(array $items): array
66  {
67  foreach ($items as $name => $item) {
68  $type = $item['type'];
69 
70  if ($type === 'submenu' && !empty($item['childItems'])) {
71  $item['childItems'] = $this->‪purgeItems($item['childItems']);
72  } elseif (!$this->‪canRender($name, $type)) {
73  unset($items[$name]);
74  }
75  }
76 
77  return $items;
78  }
79 
80  protected function ‪canBeEdited(): bool
81  {
82  return false;
83  }
84 
85  protected function ‪canBeRenamed(): bool
86  {
87  return false;
88  }
89 }
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canHandle
‪canHandle()
Definition: FormFileProvider.php:41
‪TYPO3\CMS\Form\Hooks\FormFileProvider\getPriority
‪getPriority()
Definition: FormFileProvider.php:36
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canBeRenamed
‪canBeRenamed()
Definition: FormFileProvider.php:84
‪TYPO3\CMS\Form\Hooks\FormFileProvider\purgeItems
‪purgeItems(array $items)
Definition: FormFileProvider.php:64
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canBeEdited
‪canBeEdited()
Definition: FormFileProvider.php:79
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider\initialize
‪initialize()
Definition: FileProvider.php:146
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider\canRender
‪canRender(string $itemName, string $type)
Definition: FileProvider.php:159
‪TYPO3\CMS\Form\Hooks
Definition: FormElementHooks.php:16
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
Definition: FormPersistenceManager.php:62
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider
Definition: FileProvider.php:37
‪TYPO3\CMS\Form\Hooks\FormFileProvider
Definition: FormFileProvider.php:28
‪TYPO3\CMS\Form\Hooks\FormFileProvider\$itemsConfiguration
‪array $itemsConfiguration
Definition: FormFileProvider.php:31
‪TYPO3\CMS\Form\Hooks\FormFileProvider\addItems
‪addItems(array $items)
Definition: FormFileProvider.php:47
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager\FORM_DEFINITION_FILE_EXTENSION
‪const FORM_DEFINITION_FILE_EXTENSION
Definition: FormPersistenceManager.php:63