‪TYPO3CMS  ‪main
CreateRecordReactionTable.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 
21 
28 {
29  public function ‪__construct(private readonly string $table) {}
30 
31  public static function ‪fromSelectItem(‪SelectItem $selectItem): ‪CreateRecordReactionTable
32  {
33  return new self((string)$selectItem->‪getValue());
34  }
35 
36  public function ‪isAllowedForCreation(): bool
37  {
38  return $this->‪isAllowedForItemsProcFunc()
39  && $this->‪isInSelectItems();
40  }
41 
42  public function ‪isAllowedForItemsProcFunc(): bool
43  {
44  return $this->table !== ''
45  && is_array(‪$GLOBALS['TCA'][$this->table] ?? false)
46  && !(‪$GLOBALS['TCA'][$this->table]['ctrl']['adminOnly'] ?? false);
47  }
48 
49  private function ‪isInSelectItems(): bool
50  {
51  return is_array(‪$GLOBALS['TCA']['sys_reaction']['columns']['table_name']['config']['items'] ?? false)
52  && in_array(
53  $this->table,
54  array_filter(
55  array_column(‪$GLOBALS['TCA']['sys_reaction']['columns']['table_name']['config']['items'], 'value')
56  ),
57  true
58  );
59  }
60 }
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable\fromSelectItem
‪static fromSelectItem(SelectItem $selectItem)
Definition: CreateRecordReactionTable.php:31
‪TYPO3\CMS\Reactions\Validation
Definition: CreateRecordReactionTable.php:18
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable\isInSelectItems
‪isInSelectItems()
Definition: CreateRecordReactionTable.php:49
‪TYPO3\CMS\Core\Schema\Struct\SelectItem
Definition: SelectItem.php:21
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable\__construct
‪__construct(private readonly string $table)
Definition: CreateRecordReactionTable.php:29
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable\isAllowedForItemsProcFunc
‪isAllowedForItemsProcFunc()
Definition: CreateRecordReactionTable.php:42
‪TYPO3\CMS\Core\Schema\Struct\SelectItem\getValue
‪getValue()
Definition: SelectItem.php:104
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable\isAllowedForCreation
‪isAllowedForCreation()
Definition: CreateRecordReactionTable.php:36
‪TYPO3\CMS\Reactions\Validation\CreateRecordReactionTable
Definition: CreateRecordReactionTable.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25