/**
  * Remove all nodes, workspaces, domains and sites.
  *
  * @return void
  */
 public function pruneAll()
 {
     $sites = $this->siteRepository->findAll();
     $this->nodeDataRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->domainRepository->removeAll();
     $this->siteRepository->removeAll();
     foreach ($sites as $site) {
         $this->emitSitePruned($site);
     }
 }
 /**
  * Display a list of available sites
  *
  * @return void
  */
 public function listCommand()
 {
     $sites = $this->siteRepository->findAll();
     if ($sites->count() === 0) {
         $this->outputLine('No sites available');
         $this->quit(0);
     }
     $longestSiteName = 4;
     $longestNodeName = 9;
     $longestSiteResource = 17;
     $availableSites = array();
     foreach ($sites as $site) {
         /** @var \TYPO3\Neos\Domain\Model\Site $site */
         array_push($availableSites, array('name' => $site->getName(), 'nodeName' => $site->getNodeName(), 'siteResourcesPackageKey' => $site->getSiteResourcesPackageKey()));
         if (strlen($site->getName()) > $longestSiteName) {
             $longestSiteName = strlen($site->getName());
         }
         if (strlen($site->getNodeName()) > $longestNodeName) {
             $longestNodeName = strlen($site->getNodeName());
         }
         if (strlen($site->getSiteResourcesPackageKey()) > $longestSiteResource) {
             $longestSiteResource = strlen($site->getSiteResourcesPackageKey());
         }
     }
     $this->outputLine();
     $this->outputLine(' ' . str_pad('Name', $longestSiteName + 15) . str_pad('Node name', $longestNodeName + 15) . 'Resources package');
     $this->outputLine(str_repeat('-', $longestSiteName + $longestNodeName + $longestSiteResource + 15 + 15 + 2));
     foreach ($availableSites as $site) {
         $this->outputLine(' ' . str_pad($site['name'], $longestSiteName + 15) . str_pad($site['nodeName'], $longestNodeName + 15) . $site['siteResourcesPackageKey']);
     }
     $this->outputLine();
 }
 /**
  * Show a list of sites and assigned GA profiles
  *
  * @return void
  */
 public function indexAction()
 {
     $siteConfigurations = $this->siteConfigurationRepository->findAll();
     $sites = $this->siteRepository->findAll();
     $sitesWithConfiguration = array();
     foreach ($sites as $site) {
         $item = array('site' => $site);
         foreach ($siteConfigurations as $siteConfiguration) {
             if ($siteConfiguration->getSite() === $site) {
                 $item['configuration'] = $siteConfiguration;
             }
         }
         $sitesWithConfiguration[] = $item;
     }
     $this->view->assign('sitesWithConfiguration', $sitesWithConfiguration);
     $profiles = $this->getGroupedProfiles();
     $this->view->assign('groupedProfiles', $profiles);
 }
 /**
  * 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');
 }
 /**
  * @return void
  */
 public function indexAction()
 {
     $sitePackagesAndSites = array();
     foreach ($this->packageManager->getFilteredPackages('available', null, 'typo3-flow-site') as $sitePackageKey => $sitePackage) {
         /** \TYPO3\Flow\Package\PackageInterface $sitePackage */
         $sitePackagesAndSites[strtolower(str_replace('.', '_', $sitePackageKey))] = array('package' => $sitePackage, 'packageKey' => $sitePackage->getPackageKey(), 'packageIsActive' => $this->packageManager->isPackageActive($sitePackage->getPackageKey()));
     }
     $sites = $this->siteRepository->findAll();
     foreach ($sites as $site) {
         $siteResourcePackageKey = strtolower(str_replace('.', '_', $site->getSiteResourcesPackageKey()));
         if (!isset($sitePackagesAndSites[$siteResourcePackageKey])) {
             $sitePackagesAndSites[$siteResourcePackageKey] = array('packageKey' => $site->getSiteResourcesPackageKey());
         }
         if (!isset($sitePackagesAndSites[$siteResourcePackageKey]['sites'])) {
             $sitePackagesAndSites[$siteResourcePackageKey]['sites'] = array();
         }
         $sitePackagesAndSites[$siteResourcePackageKey]['sites'][] = $site;
     }
     $this->view->assignMultiple(array('sitePackagesAndSites' => $sitePackagesAndSites, 'multipleSites' => count($sites) > 1));
 }
 /**
  * Remove all sites and their respective nodes and domains
  *
  * @return void
  */
 public function pruneAll()
 {
     foreach ($this->siteRepository->findAll() as $site) {
         $this->pruneSite($site);
     }
 }