コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
 /**
  * @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;
 }
コード例 #7
0
ファイル: PostProcessor.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * 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;
 }
コード例 #8
0
 /**
  * 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);
 }
コード例 #9
0
 /**
  * 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);
 }
コード例 #10
0
ファイル: FilterUtility.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * 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;
 }
コード例 #11
0
 /**
  * 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;
 }