TYPO3 CMS  TYPO3_8-7
GridContainer.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 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 
29 {
30 
37  public function registerInFormIfPossible()
38  {
39  foreach ($this->getElementsRecursively() as $renderable) {
40  if ($renderable instanceof GridContainerInterface) {
42  sprintf('Grid containers ("%s") within grid containers ("%s") are not allowed.', $renderable->getIdentifier(), $this->getIdentifier()),
43  1489412790
44  );
45  }
46  }
47  parent::registerInFormIfPossible();
48  }
49 
56  public function addElement(FormElementInterface $formElement)
57  {
58  if (!$formElement instanceof GridRowInterface) {
60  sprintf('The "implementationClassName" for element "%s" (type "%s") does not implement the GridRowInterface.', $formElement->getIdentifier(), $formElement->getType()),
61  1489486301
62  );
63  }
64  $this->addRenderable($formElement);
65  }
66 
76  public function createElement(string $identifier, string $typeName): FormElementInterface
77  {
78  $element = parent::createElement($identifier, $typeName);
79 
80  if (!$element instanceof GridRowInterface) {
82  sprintf('The "implementationClassName" for element "%s" (type "%s") does not implement the GridRowInterface.', $identifier, $typeName),
83  1489486302
84  );
85  }
86  return $element;
87  }
88 }
createElement(string $identifier, string $typeName)
addElement(FormElementInterface $formElement)