/** * Returns the form definitions for the step * * @param \TYPO3\Form\Core\Model\FormDefinition $formDefinition * @return void */ protected function buildForm(\TYPO3\Form\Core\Model\FormDefinition $formDefinition) { $page1 = $formDefinition->createPage('page1'); $page1->setRenderingOption('header', 'Create a new site'); $introduction = $page1->createElement('introduction', 'TYPO3.Form:StaticText'); $introduction->setProperty('text', 'There are two ways of creating a site. Choose between the following:'); $importSection = $page1->createElement('import', 'TYPO3.Form:Section'); $importSection->setLabel('Import a site from an existing site package'); $sitePackages = array(); foreach ($this->packageManager->getFilteredPackages('available', NULL, 'typo3-flow-site') as $package) { $sitePackages[$package->getPackageKey()] = $package->getPackageKey(); } if (count($sitePackages) > 0) { $site = $importSection->createElement('site', 'TYPO3.Form:SingleSelectDropdown'); $site->setLabel('Select a site package'); $site->setProperty('options', $sitePackages); $site->addValidator(new \TYPO3\Flow\Validation\Validator\NotEmptyValidator()); $sites = $this->siteRepository->findAll(); if ($sites->count() > 0) { $prune = $importSection->createElement('prune', 'TYPO3.Form:Checkbox'); $prune->setLabel('Delete existing sites'); } } else { $error = $importSection->createElement('noSitePackagesError', 'TYPO3.Form:StaticText'); $error->setProperty('text', 'No site packages were available, make sure you have an active site package'); $error->setProperty('elementClassAttribute', 'alert alert-warning'); } if ($this->packageManager->isPackageActive('TYPO3.Neos.Kickstarter')) { $separator = $page1->createElement('separator', 'TYPO3.Form:StaticText'); $separator->setProperty('elementClassAttribute', 'section-separator'); $newPackageSection = $page1->createElement('newPackageSection', 'TYPO3.Form:Section'); $newPackageSection->setLabel('Create a new site package with a dummy site'); $packageName = $newPackageSection->createElement('packageKey', 'TYPO3.Form:SingleLineText'); $packageName->setLabel('Package Name (in form "Vendor.DomainCom")'); $packageName->addValidator(new \TYPO3\Neos\Validation\Validator\PackageKeyValidator()); $siteName = $newPackageSection->createElement('siteName', 'TYPO3.Form:SingleLineText'); $siteName->setLabel('Site Name (e.g. "domain.com")'); } else { $error = $importSection->createElement('neosKickstarterUnavailableError', 'TYPO3.Form:StaticText'); $error->setProperty('text', 'The Neos Kickstarter package (TYPO3.Neos.Kickstarter) is not installed, install it for kickstarting new sites (using "composer require typo3/neos-kickstarter")'); $error->setProperty('elementClassAttribute', 'alert alert-warning'); } $explanation = $page1->createElement('explanation', 'TYPO3.Form:StaticText'); $explanation->setProperty('text', 'Notice the difference between a site package and a site. A site package is a Flow package that can be used for creating multiple site instances.'); $explanation->setProperty('elementClassAttribute', 'alert alert-info'); $step = $this; $callback = function (\TYPO3\Form\Core\Model\FinisherContext $finisherContext) use($step) { $step->importSite($finisherContext); }; $this->closureFinisher = new \TYPO3\Form\Finishers\ClosureFinisher(); $this->closureFinisher->setOption('closure', $callback); $formDefinition->addFinisher($this->closureFinisher); $formDefinition->setRenderingOption('skipStepNotice', 'You can always import a site using the site:import command'); }
/** * Returns the form definitions for the step * * @param \TYPO3\Form\Core\Model\FormDefinition $formDefinition * @return void */ protected function buildForm(\TYPO3\Form\Core\Model\FormDefinition $formDefinition) { $page1 = $formDefinition->createPage('page1'); $title = $page1->createElement('connectionSection', 'TYPO3.Form:Section'); $title->setLabel('Import a site'); $sitePackages = array(); foreach ($this->packageManager->getActivePackages() as $package) { $packageMetaData = $package->getPackageMetaData(); if (in_array('Site', $packageMetaData->getCategories())) { $sitePackages[$package->getPackageKey()] = $packageMetaData->getTitle(); } } if (count($sitePackages) > 0) { $site = $title->createElement('site', 'TYPO3.Form:SingleSelectDropdown'); $site->setLabel('Select a site'); $site->setProperty('options', $sitePackages); $site->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator()); $sites = $this->siteRepository->findAll(); if ($sites->count() > 0) { $prune = $title->createElement('prune', 'TYPO3.Form:Checkbox'); $prune->setLabel('Delete existing sites'); } } else { $error = $title->createElement('error', 'TYPO3.Form:StaticText'); $error->setProperty('text', 'No site packages were available, make sure you have an active site package'); $error->setProperty('class', 'alert alert-warning'); } $newPackageSection = $page1->createElement('newPackageSection', 'TYPO3.Form:Section'); $newPackageSection->setLabel('Create a new site'); $packageName = $newPackageSection->createElement('packageKey', 'TYPO3.Form:SingleLineText'); $packageName->setLabel('Package Name (in form "Vendor.MyPackageName")'); $packageName->addValidator(new \TYPO3\FLOW3\Validation\Validator\RegularExpressionValidator(array('regularExpression' => \TYPO3\FLOW3\Package\PackageInterface::PATTERN_MATCH_PACKAGEKEY))); $siteName = $newPackageSection->createElement('siteName', 'TYPO3.Form:SingleLineText'); $siteName->setLabel('Site Name'); $step = $this; $callback = function (\TYPO3\Form\Core\Model\FinisherContext $finisherContext) use($step) { $step->importSite($finisherContext); }; $this->closureFinisher = new \TYPO3\Form\Finishers\ClosureFinisher(); $this->closureFinisher->setOption('closure', $callback); $formDefinition->addFinisher($this->closureFinisher); }