‪TYPO3CMS  9.5
UnknownFormElement.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 
30 {
31 
39  public function ‪__construct(string ‪$identifier, string ‪$type)
40  {
41  if (!is_string(‪$identifier) || strlen(‪$identifier) === 0) {
42  throw new ‪IdentifierNotValidException('The given identifier was not a string or the string was empty.', 1382364370);
43  }
44  $this->identifier = ‪$identifier;
45  $this->type = ‪$type;
46  }
47 
51  public function ‪initializeFormElement()
52  {
53  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['initializeFormElement'] ?? [] as $className) {
54  $hookObj = GeneralUtility::makeInstance($className);
55  if (method_exists($hookObj, 'initializeFormElement')) {
56  $hookObj->initializeFormElement(
57  $this
58  );
59  }
60  }
61  }
62 
70  public function ‪getUniqueIdentifier(): string
71  {
72  $formDefinition = $this->‪getRootForm();
73  $uniqueIdentifier = sprintf('%s-%s', $formDefinition->getIdentifier(), $this->identifier);
74  $uniqueIdentifier = preg_replace('/[^a-zA-Z0-9-_]/', '_', $uniqueIdentifier);
75  return lcfirst($uniqueIdentifier);
76  }
77 
83  public function ‪getTemplateName(): string
84  {
85  return 'UnknownElement';
86  }
87 
92  public function ‪getDefaultValue()
93  {
94  return null;
95  }
96 
103  public function ‪setDefaultValue($defaultValue)
104  {
105  }
106 
114  public function ‪setProperty(string $key, $value)
115  {
116  }
117 
122  public function ‪getProperties(): array
123  {
124  return [];
125  }
126 
131  public function ‪isRequired(): bool
132  {
133  return false;
134  }
135 }
‪TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException
Definition: IdentifierNotValidException.php:27
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\isRequired
‪bool isRequired()
Definition: UnknownFormElement.php:131
‪TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable
Definition: AbstractRenderable.php:38
‪TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable\$type
‪string $type
Definition: AbstractRenderable.php:46
‪TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable\getRootForm
‪FormDefinition getRootForm()
Definition: AbstractRenderable.php:313
‪TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface
Definition: FormElementInterface.php:36
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\getTemplateName
‪string getTemplateName()
Definition: UnknownFormElement.php:83
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\getProperties
‪array getProperties()
Definition: UnknownFormElement.php:122
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\getUniqueIdentifier
‪string getUniqueIdentifier()
Definition: UnknownFormElement.php:70
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement
Definition: UnknownFormElement.php:30
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\__construct
‪__construct(string $identifier, string $type)
Definition: UnknownFormElement.php:39
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\getDefaultValue
‪mixed getDefaultValue()
Definition: UnknownFormElement.php:92
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable\$identifier
‪string $identifier
Definition: AbstractRenderable.php:52
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\initializeFormElement
‪initializeFormElement()
Definition: UnknownFormElement.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\setDefaultValue
‪setDefaultValue($defaultValue)
Definition: UnknownFormElement.php:103
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement\setProperty
‪setProperty(string $key, $value)
Definition: UnknownFormElement.php:114
‪TYPO3\CMS\Form\Domain\Model\FormElements
Definition: AbstractFormElement.php:3