‪TYPO3CMS  ‪main
ModifyFileReferenceEnabledControlsEvent.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 
24 {
28  private array ‪$controlsState;
29 
30  public function ‪__construct(
31  private readonly array $data,
32  private readonly array ‪$record,
33  ) {
34  $this->controlsState = (array)($data['inlineParentConfig']['appearance']['enabledControls'] ?? []);
35  }
36 
42  public function ‪enableControl(string ‪$identifier): bool
43  {
44  if (!$this->‪hasControl($identifier)) {
45  return false;
46  }
47 
48  $this->controlsState[‪$identifier] = true;
49  return true;
50  }
51 
57  public function ‪disableControl(string ‪$identifier): bool
58  {
59  if (!$this->‪hasControl($identifier)) {
60  return false;
61  }
62 
63  $this->controlsState[‪$identifier] = false;
64  return true;
65  }
66 
70  public function ‪hasControl(string ‪$identifier): bool
71  {
72  return isset($this->controlsState[‪$identifier]);
73  }
74 
79  public function ‪isControlEnabled(string ‪$identifier): bool
80  {
81  return (bool)($this->controlsState[‪$identifier] ?? false);
82  }
83 
87  public function ‪getControlsState(): array
88  {
90  }
91 
95  public function ‪getEnabledControls(): array
96  {
97  return array_filter($this->controlsState, static fn(mixed $control): bool => (bool)$control === true);
98  }
99 
103  public function ‪getElementData(): array
104  {
105  return $this->data;
106  }
107 
111  public function ‪getRecord(): array
112  {
113  return ‪$this->record;
114  }
115 
119  public function ‪getParentUid(): string
120  {
121  return (string)($this->data['inlineParentUid'] ?? '');
122  }
123 
127  public function ‪getForeignTable(): string
128  {
129  return (string)($this->‪getFieldConfiguration()['foreign_table'] ?? '');
130  }
131 
135  public function ‪getFieldConfiguration(): array
136  {
137  return (array)($this->data['inlineParentConfig'] ?? []);
138  }
139 
143  public function ‪isVirtual(): bool
144  {
145  return (bool)($this->data['isInlineDefaultLanguageRecordInLocalizedParentContext'] ?? false);
146  }
147 }
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getFieldConfiguration
‪getFieldConfiguration()
Definition: ModifyFileReferenceEnabledControlsEvent.php:135
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getControlsState
‪getControlsState()
Definition: ModifyFileReferenceEnabledControlsEvent.php:87
‪TYPO3\CMS\Backend\Form\Event
Definition: CustomFileControlsEvent.php:18
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\disableControl
‪bool disableControl(string $identifier)
Definition: ModifyFileReferenceEnabledControlsEvent.php:57
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\enableControl
‪bool enableControl(string $identifier)
Definition: ModifyFileReferenceEnabledControlsEvent.php:42
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getEnabledControls
‪getEnabledControls()
Definition: ModifyFileReferenceEnabledControlsEvent.php:95
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\$controlsState
‪array $controlsState
Definition: ModifyFileReferenceEnabledControlsEvent.php:28
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\hasControl
‪hasControl(string $identifier)
Definition: ModifyFileReferenceEnabledControlsEvent.php:70
‪TYPO3\CMS\Webhooks\Message\$record
‪identifier readonly int readonly array $record
Definition: PageModificationMessage.php:36
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\isControlEnabled
‪isControlEnabled(string $identifier)
Definition: ModifyFileReferenceEnabledControlsEvent.php:79
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\isVirtual
‪isVirtual()
Definition: ModifyFileReferenceEnabledControlsEvent.php:143
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getRecord
‪getRecord()
Definition: ModifyFileReferenceEnabledControlsEvent.php:111
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getParentUid
‪getParentUid()
Definition: ModifyFileReferenceEnabledControlsEvent.php:119
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent
Definition: ModifyFileReferenceEnabledControlsEvent.php:24
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\__construct
‪__construct(private readonly array $data, private readonly array $record,)
Definition: ModifyFileReferenceEnabledControlsEvent.php:30
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getForeignTable
‪getForeignTable()
Definition: ModifyFileReferenceEnabledControlsEvent.php:127
‪TYPO3\CMS\Backend\Form\Event\ModifyFileReferenceEnabledControlsEvent\getElementData
‪getElementData()
Definition: ModifyFileReferenceEnabledControlsEvent.php:103