Inheritance: extends FluidTYPO3\Flux\Form\AbstractFormContainer, implements FluidTYPO3\Flux\Form\ContainerInterface
Esempio n. 1
0
 /**
  * @param array $settings
  * @return FieldInterface
  * @throws \RuntimeException
  */
 public static function create(array $settings = array())
 {
     /** @var ObjectManagerInterface $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     if ('Section' === $settings['type']) {
         return Section::create($settings);
     } else {
         $prefix = 'FluidTYPO3\\Flux\\Form\\Field\\';
         $type = $settings['type'];
         $className = str_replace('/', '\\', $type);
         $className = TRUE === class_exists($prefix . $className) ? $prefix . $className : $className;
     }
     if (FALSE === class_exists($className)) {
         $className = $settings['type'];
     }
     if (FALSE === class_exists($className)) {
         throw new \RuntimeException('Invalid class- or type-name used in type of field "' . $settings['name'] . '"; "' . $className . '" is invalid', 1375373527);
     }
     /** @var FormInterface $object */
     $object = $objectManager->get($className);
     foreach ($settings as $settingName => $settingValue) {
         $setterMethodName = 'set' . ucfirst($settingName);
         if (TRUE === method_exists($object, $setterMethodName)) {
             call_user_func_array(array($object, $setterMethodName), array($settingValue));
         }
     }
     return $object;
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function canCreateFromDefinitionWithObjects()
 {
     $definition = array('name' => 'test', 'label' => 'Test section', 'objects' => array('object1' => array('label' => 'Test object', 'fields' => array('foo' => array('type' => 'Input', 'label' => 'Foo input')))));
     $section = Section::create($definition);
     $this->assertInstanceOf('FluidTYPO3\\Flux\\Form\\Container\\Section', $section);
 }