‪TYPO3CMS  11.5
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 
39  public function ‪getPriority(): int
40  {
41  return 0;
42  }
43 
47  public function ‪canHandle(): bool
48  {
49  return parent::canHandle()
50  && str_ends_with($this->identifier, ‪FormPersistenceManager::FORM_DEFINITION_FILE_EXTENSION);
51  }
52 
57  public function ‪addItems(array $items): array
58  {
59  $this->‪initialize();
60  return $this->‪purgeItems($items);
61  }
62 
75  protected function ‪purgeItems(array $items): array
76  {
77  foreach ($items as $name => $item) {
78  $type = $item['type'];
79 
80  if ($type === 'submenu' && !empty($item['childItems'])) {
81  $item['childItems'] = $this->‪purgeItems($item['childItems']);
82  } elseif (!$this->‪canRender($name, $type)) {
83  unset($items[$name]);
84  }
85  }
86 
87  return $items;
88  }
89 
93  protected function ‪canBeEdited(): bool
94  {
95  return false;
96  }
97 
101  protected function ‪canBeRenamed(): bool
102  {
103  return false;
104  }
105 }
‪TYPO3\CMS\Form\Hooks\FormFileProvider\getPriority
‪int getPriority()
Definition: FormFileProvider.php:38
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canBeRenamed
‪bool canBeRenamed()
Definition: FormFileProvider.php:100
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider\initialize
‪initialize()
Definition: FileProvider.php:137
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canBeEdited
‪bool canBeEdited()
Definition: FormFileProvider.php:92
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider\canRender
‪bool canRender(string $itemName, string $type)
Definition: FileProvider.php:154
‪TYPO3\CMS\Form\Hooks
Definition: DataStructureIdentifierHook.php:18
‪TYPO3\CMS\Form\Hooks\FormFileProvider\addItems
‪array addItems(array $items)
Definition: FormFileProvider.php:56
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
Definition: FormPersistenceManager.php:54
‪TYPO3\CMS\Filelist\ContextMenu\ItemProviders\FileProvider
Definition: FileProvider.php:35
‪TYPO3\CMS\Form\Hooks\FormFileProvider\canHandle
‪bool canHandle()
Definition: FormFileProvider.php:46
‪TYPO3\CMS\Form\Hooks\FormFileProvider
Definition: FormFileProvider.php:28
‪TYPO3\CMS\Form\Hooks\FormFileProvider\purgeItems
‪array purgeItems(array $items)
Definition: FormFileProvider.php:74
‪TYPO3\CMS\Form\Hooks\FormFileProvider\$itemsConfiguration
‪array $itemsConfiguration
Definition: FormFileProvider.php:31
‪TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager\FORM_DEFINITION_FILE_EXTENSION
‪const FORM_DEFINITION_FILE_EXTENSION
Definition: FormPersistenceManager.php:55