/** * 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 \TYPO3\Form\Core\Model\Page the newly created page * @throws \TYPO3\Form\Exception\TypeDefinitionNotFoundException * @api */ public function createPage($identifier, $typeName = 'TYPO3.Form:Page') { $typeDefinition = $this->formFieldTypeManager->getMergedTypeDefinition($typeName); if (!isset($typeDefinition['implementationClassName'])) { throw new \TYPO3\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); } } \TYPO3\Form\Utility\Arrays::assertAllArrayKeysAreValid($typeDefinition, array('implementationClassName', 'label', 'rendererClassName', 'renderingOptions')); $this->addPage($page); return $page; }
/** * @test * @expectedException TYPO3\Form\Exception\TypeDefinitionNotFoundException */ public function getMergedTypeDefinitionThrowsExceptionIfTypeNotFound() { $supertypeResolver = new SupertypeResolver(array()); $supertypeResolver->getMergedTypeDefinition('nonExistingType'); }