/**
  * Display a list of available domain records
  *
  * @param string $hostPattern An optional host pattern to search for
  * @return void
  */
 public function listCommand($hostPattern = null)
 {
     if ($hostPattern === null) {
         $domains = $this->domainRepository->findAll();
     } else {
         $domains = $this->domainRepository->findByHost($hostPattern);
     }
     if (count($domains) === 0) {
         $this->outputLine('No domains available.');
         $this->quit(0);
     }
     $longestNodeName = 9;
     $longestHostPattern = 12;
     $availableDomains = array();
     foreach ($domains as $domain) {
         /** @var \TYPO3\Neos\Domain\Model\Domain $domain */
         array_push($availableDomains, array('nodeName' => $domain->getSite()->getNodeName(), 'hostPattern' => $domain->getHostPattern(), 'active' => $domain->getActive()));
         if (strlen($domain->getSite()->getNodeName()) > $longestNodeName) {
             $longestNodeName = strlen($domain->getSite()->getNodeName());
         }
         if (strlen($domain->getHostPattern()) > $longestHostPattern) {
             $longestHostPattern = strlen($domain->getHostPattern());
         }
     }
     $this->outputLine();
     $this->outputLine(' ' . str_pad('Node name', $longestNodeName + 10) . str_pad('Host pattern', $longestHostPattern + 5) . 'State');
     $this->outputLine(str_repeat('-', $longestNodeName + $longestHostPattern + 10 + 2 + 14));
     foreach ($availableDomains as $domain) {
         $this->outputLine(' ' . str_pad($domain['nodeName'], $longestNodeName + 10) . str_pad($domain['hostPattern'], $longestHostPattern + 5) . ($domain['active'] ? 'Active' : 'Inactive'));
     }
     $this->outputLine();
 }
 /**
  * Display a list of available domain records
  *
  * @param string $hostPattern An optional host pattern to search for
  * @return void
  */
 public function listCommand($hostPattern = null)
 {
     if ($hostPattern === null) {
         $domains = $this->domainRepository->findAll();
     } else {
         $domains = $this->domainRepository->findByHost($hostPattern);
     }
     if (count($domains) === 0) {
         $this->outputLine('No domains available.');
         $this->quit(0);
     }
     $longestNodeName = 9;
     $longestHostPattern = 12;
     $availableDomains = array();
     foreach ($domains as $domain) {
         /** @var Domain $domain */
         array_push($availableDomains, array('nodeName' => $domain->getSite()->getNodeName(), 'hostPattern' => $domain->getHostPattern(), 'scheme' => $domain->getScheme(), 'port' => $domain->getPort(), 'active' => $domain->getActive()));
         if (strlen($domain->getSite()->getNodeName()) > $longestNodeName) {
             $longestNodeName = strlen($domain->getSite()->getNodeName());
         }
         if (strlen($domain) > $longestHostPattern) {
             $longestHostPattern = strlen($domain);
         }
     }
     $this->outputLine();
     $this->outputLine(' ' . str_pad('Node name', $longestNodeName + 10) . str_pad('Domain (Scheme/<b>Host</b>/Port)', $longestHostPattern + 12) . 'State');
     $this->outputLine(str_repeat('-', $longestNodeName + $longestHostPattern + 10 + 2 + 12));
     foreach ($availableDomains as $domain) {
         $this->outputLine(sprintf(' %s%s%s', str_pad($domain['nodeName'], $longestNodeName + 10), str_pad(($domain['scheme'] ? $domain['scheme'] . '://' : '') . '<b>' . $domain['hostPattern'] . '</b>' . ($domain['port'] ? ':' . $domain['port'] : ''), $longestHostPattern + 12), $domain['active'] ? 'Active' : 'Inactive'));
     }
     $this->outputLine();
 }