* @package tao */ class WizardForm extends \tao_helpers_form_FormContainer { /** * @return mixed|void * @throws \common_Exception */ protected function initForm() { $this->form = new \tao_helpers_form_xhtml_Form('simpleWizard'); $createElt = \tao_helpers_form_FormFactory::getElement('create', 'Free'); $createElt->setValue(''); $this->form->setDecorators([ 'actions-bottom' => new \tao_helpers_form_xhtml_TagWrapper(['tag' => 'div', 'cssClass' => 'form-toolbar']), ]); $this->form->setActions([], 'top'); $this->form->setActions([$createElt], 'bottom'); } /** * @author Joel Bout, * @return mixed|void * @throws NoTestsException * @throws \common_Exception * @throws \common_exception_Error */ public function initElements() { $class = $this->data['class']; if (!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); /** @var \tao_helpers_form_elements_xhtml_Hidden $testElt */ $testElt = \tao_helpers_form_FormFactory::getElement('test', 'Hidden'); /** @var ComplexSearchService $search */ $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query(); $query = $search->searchType($queryBuilder, TaoOntology::TEST_CLASS_URI, true); $queryBuilder->setCriteria($query); $count = $search->getGateway()->count($queryBuilder); if (0 === $count) { throw new NoTestsException(); } $selectElt = \tao_helpers_form_FormFactory::getElement('selectelt', 'Free'); $selectElt->setValue('
'); $this->form->addElement($selectElt); $testElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($testElt); $this->initCustomElements(); } public function initCustomElements() { $deliveryPublishingService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID); if ($deliveryPublishingService->hasOption(DeliveryFactory::OPTION_INITIAL_PROPERTIES)) { $initialProperties = $deliveryPublishingService->getOption(DeliveryFactory::OPTION_INITIAL_PROPERTIES); foreach ($initialProperties as $uri) { $property = new \core_kernel_classes_Property($uri); $element = \tao_helpers_form_GenerisFormFactory::elementMap($property); $this->form->addElement($element); } } } /**r * @return ServiceManager */ protected function getServiceManager() { return ServiceManager::getServiceManager(); } }