/** * Create a page with the given $identifier and attach this page to the form. * * - Create Page object based on the given $typeName * - set defaults inside the Page object * - attach Page object to this form * - return the newly created Page object * * @param string $identifier Identifier of the new page * @param string $typeName Type of the new page * @return \Neos\Form\Core\Model\Page the newly created page * @throws \Neos\Form\Exception\TypeDefinitionNotFoundException * @api */ public function createPage($identifier, $typeName = 'Neos.Form:Page') { $typeDefinition = $this->formFieldTypeManager->getMergedTypeDefinition($typeName); if (!isset($typeDefinition['implementationClassName'])) { throw new \Neos\Form\Exception\TypeDefinitionNotFoundException(sprintf('The "implementationClassName" was not set in type definition "%s".', $typeName), 1325689855); } $implementationClassName = $typeDefinition['implementationClassName']; $page = new $implementationClassName($identifier, $typeName); if (isset($typeDefinition['label'])) { $page->setLabel($typeDefinition['label']); } if (isset($typeDefinition['rendererClassName'])) { $page->setRendererClassName($typeDefinition['rendererClassName']); } if (isset($typeDefinition['renderingOptions'])) { foreach ($typeDefinition['renderingOptions'] as $key => $value) { $page->setRenderingOption($key, $value); } } \Neos\Form\Utility\Arrays::assertAllArrayKeysAreValid($typeDefinition, array('implementationClassName', 'label', 'rendererClassName', 'renderingOptions')); $this->addPage($page); return $page; }
/** * Set multiple properties of this object at once. * Every property which has a corresponding set* method can be set using * the passed $options array. * * @param array $options * @return void * @internal */ public function setOptions(array $options) { if (isset($options['label'])) { $this->setLabel($options['label']); } if (isset($options['defaultValue'])) { $this->setDefaultValue($options['defaultValue']); } if (isset($options['properties'])) { foreach ($options['properties'] as $key => $value) { $this->setProperty($key, $value); } } if (isset($options['rendererClassName'])) { $this->setRendererClassName($options['rendererClassName']); } if (isset($options['renderingOptions'])) { foreach ($options['renderingOptions'] as $key => $value) { $this->setRenderingOption($key, $value); } } if (isset($options['validators'])) { foreach ($options['validators'] as $validatorConfiguration) { $this->createValidator($validatorConfiguration['identifier'], isset($validatorConfiguration['options']) ? $validatorConfiguration['options'] : array()); } } \Neos\Form\Utility\Arrays::assertAllArrayKeysAreValid($options, array('label', 'defaultValue', 'properties', 'rendererClassName', 'renderingOptions', 'validators')); }