/** * Create a rule object according to class * and sent some arguments * * @param string $class Name of the validation rule * @param array $arguments Configuration of the rule * @return AbstractValidator The rule object */ public function createRule($class, $arguments = array()) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\Validation\\' . ucfirst($class) . 'Validator'; $rule = ObjectFactory::createFormObject($className, $arguments); return $rule; }
/** * Add an attribute object to the attribute array * * @param string $class Name of the attribute * @param mixed $value Typoscript configuration to construct value * @return \TYPO3\CMS\Form\Domain\Model\Attribute\AbstractAttribute */ public function addAttribute($class, $value) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\Attribute\\' . ucfirst($class) . 'Attribute'; $this->attributes[$class] = ObjectFactory::createFormObject($className, $value, $this->elementId); return $this; }
/** * Add an additional object to the additional array * * @param string $class Name of the additional * @param mixed $value Typoscript configuration to construct value * @param string $type Typoscript content object * @return AdditionalAdditionalElement */ public function addAdditional($class, $type, $value) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\Additional\\' . ucfirst($class) . 'AdditionalElement'; $this->additional[$class] = ObjectFactory::createFormObject($className, $type, $value); return $this; }
/** * Create child object from the classname of the model * * @param AbstractElement $modelChild The childs model * @return \TYPO3\CMS\Form\View\Form\Element\AbstractElementView */ public function createChildElementFromModel($modelChild) { $childElement = NULL; $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild); $className = 'TYPO3\\CMS\\Form\\View\\Form\\Element\\' . ucfirst($class) . 'ElementView'; if (class_exists($className)) { $childElement = ObjectFactory::createFormObject($className, $modelChild); } return $childElement; }
/** * Create element by loading class * and instantiating the object * * @param string $class Type of element * @param array $arguments Configuration array * @return AbstractJsonElement */ public function createElement($class, array $arguments = array()) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\Json\\' . ucfirst($class) . 'JsonElement'; $this->addValidationRules($arguments); /** @var $object AbstractJsonElement */ $object = ObjectFactory::createFormObject($className); $object->setParameters($arguments); if ($object->childElementsAllowed()) { $this->getChildElementsByIntegerKey($object, $arguments); } return $object; }
/** * @param \TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild * @param int $spaces * @return string */ protected function renderChild(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild, $spaces) { $content = ''; $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild); $className = 'TYPO3\\CMS\\Form\\View\\Mail\\Plain\\Element\\' . ucfirst($class) . 'ElementView'; if (class_exists($className)) { /** @var $childElement \TYPO3\CMS\Form\View\Mail\Plain\Element\AbstractElementView */ $childElement = ObjectFactory::createFormObject($className, $modelChild, $spaces); $elementContent = $childElement->render(); if ($elementContent != '') { $content = $childElement->render() . LF; } } return $content; }
/** * The main method called by the controller * * Iterates over the configured post processors and calls them with their * own settings * * @return string HTML messages from the called processors */ public function process() { $html = ''; if (is_array($this->typoScript)) { $keys = $this->sortTypoScriptKeyList(); $layoutHandler = $this->typoscriptFactory->setLayoutHandler($this->typoScript); foreach ($keys as $key) { if (!(int) $key || strpos($key, '.') !== FALSE) { continue; } $className = FALSE; $processorName = $this->typoScript[$key]; $processorArguments = array(); if (isset($this->typoScript[$key . '.'])) { $processorArguments = $this->typoScript[$key . '.']; } if (class_exists($processorName, TRUE)) { $className = $processorName; } else { $classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor'; if (class_exists($classNameExpanded, TRUE)) { $className = $classNameExpanded; } } if ($className !== FALSE) { $layout = $this->typoscriptFactory->getLayoutFromTypoScript($this->typoScript[$processorName . '.']); $layoutHandler->setLayout($layout); $processor = ObjectFactory::createFormObject($className, $this->form, $processorArguments); if ($processor instanceof PostProcessorInterface) { $html .= $processor->process(); } } } } return $html; }
/** * Load and instantiate an additional object * * @param string $class Type of additional * @return AdditionalElementView */ protected function createAdditional($class) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\View\\Mail\\Html\\Additional\\' . ucfirst($class) . 'AdditionalElementView'; return ObjectFactory::createFormObject($className, $this->model); }
/** * Load the attributes object * * @return void */ protected function createAttributes() { $className = \TYPO3\CMS\Form\Domain\Model\Attribute\AttributesAttribute::class; $this->attributes = ObjectFactory::createFormObject($className, $this->elementId); }
/** * Create a filter object according to class * and sent some arguments * * @param string $class Name of the filter * @param array $arguments Configuration of the filter * @return \TYPO3\CMS\Form\Filter\FilterInterface The filter object */ public static function createFilter($class, array $arguments = NULL) { $class = strtolower((string) $class); $className = 'TYPO3\\CMS\\Form\\Filter\\' . ucfirst($class) . 'Filter'; if (is_null($arguments)) { $filter = ObjectFactory::createFormObject($className); } else { $filter = ObjectFactory::createFormObject($className, $arguments); } return $filter; }
/** * Create element by loading class * and instantiating the object * * @param string $class Type of element * @param array $arguments Configuration array * @return AbstractElement * @throws \InvalidArgumentException */ public function createElement($class, array $arguments = array()) { $class = strtolower((string) $class); if ($class === 'form') { $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\' . ucfirst($class); } else { $className = 'TYPO3\\CMS\\Form\\Domain\\Model\\Element\\' . ucfirst($class) . 'Element'; } /* @var $object AbstractElement */ $object = ObjectFactory::createFormObject($className); if ($object->getElementType() === AbstractElement::ELEMENT_TYPE_CONTENT) { $object->setData($arguments['cObj'], $arguments['cObj.']); } elseif ($object->getElementType() === AbstractElement::ELEMENT_TYPE_PLAIN) { /* @var $object \TYPO3\CMS\Form\Domain\Model\Element\AbstractPlainElement */ $object->setProperties($arguments); } elseif ($object->getElementType() === AbstractElement::ELEMENT_TYPE_FORM) { $object->setData($arguments['data']); $this->reconstituteElement($object, $arguments); } else { throw new \InvalidArgumentException('Element type "' . $object->getElementType() . '" is not supported.', 1333754878); } return $object; }