‪TYPO3CMS  9.5
Section.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It originated from the Neos.Form package (www.neos.io)
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
23 
35 {
36 
40  protected ‪$properties = [];
41 
48  public function ‪initializeFormElement()
49  {
50  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] ?? [] as $className) {
51  $hookObj = GeneralUtility::makeInstance($className);
52  if (method_exists($hookObj, 'initializeFormElement')) {
53  $hookObj->initializeFormElement(
54  $this
55  );
56  }
57  }
58  }
59 
67  public function ‪getUniqueIdentifier(): string
68  {
69  $formDefinition = $this->‪getRootForm();
70  return sprintf('%s-%s', $formDefinition->getIdentifier(), $this->identifier);
71  }
72 
80  public function ‪getDefaultValue()
81  {
82  return null;
83  }
84 
92  public function ‪setDefaultValue($defaultValue)
93  {
94  }
95 
101  public function ‪getProperties(): array
102  {
103  return ‪$this->properties;
104  }
105 
112  public function ‪setProperty(string $key, $value)
113  {
114  if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) {
115  ‪ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value);
116  $this->properties[$key] = ‪ArrayUtility::removeNullValuesRecursive($this->properties[$key]);
117  } elseif ($value === null) {
118  unset($this->properties[$key]);
119  } else {
120  $this->properties[$key] = $value;
121  }
122  }
123 
129  public function ‪isRequired(): bool
130  {
131  foreach ($this->‪getValidators() as ‪$validator) {
132  if (‪$validator instanceof ‪NotEmptyValidator) {
133  return true;
134  }
135  }
136  return false;
137  }
138 }
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\$properties
‪array $properties
Definition: Section.php:39
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\setDefaultValue
‪setDefaultValue($defaultValue)
Definition: Section.php:91
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section
Definition: Section.php:35
‪TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule
‪static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
Definition: ArrayUtility.php:614
‪TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable\getRootForm
‪FormDefinition getRootForm()
Definition: AbstractRenderable.php:313
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\setProperty
‪setProperty(string $key, $value)
Definition: Section.php:111
‪TYPO3\CMS\Form\Domain\Model\FormElements\AbstractSection
Definition: AbstractSection.php:40
‪TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface
Definition: FormElementInterface.php:36
‪$validator
‪if(isset($args['d'])) $validator
Definition: validateRstFiles.php:218
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\getUniqueIdentifier
‪string getUniqueIdentifier()
Definition: Section.php:66
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\getDefaultValue
‪mixed getDefaultValue()
Definition: Section.php:79
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\getProperties
‪array getProperties()
Definition: Section.php:100
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\isRequired
‪bool isRequired()
Definition: Section.php:128
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\ArrayUtility\removeNullValuesRecursive
‪static array removeNullValuesRecursive(array $array)
Definition: ArrayUtility.php:232
‪TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator
Definition: NotEmptyValidator.php:21
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section\initializeFormElement
‪initializeFormElement()
Definition: Section.php:47
‪TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface\getValidators
‪SplObjectStorage< ValidatorInterface > getValidators()
‪TYPO3\CMS\Form\Domain\Model\FormElements
Definition: AbstractFormElement.php:3