/** * 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) { array_push($availableDomains, array('nodeName' => $domain->getSite()->getNodeName(), 'hostPattern' => $domain->getHostPattern())); 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 + 15) . 'Host pattern'); $this->outputLine(str_repeat('-', $longestNodeName + $longestHostPattern + 15 + 2)); foreach ($availableDomains as $domain) { $this->outputLine(' ' . str_pad($domain['nodeName'], $longestNodeName + 15) . $domain['hostPattern']); } $this->outputLine(); }
/** * Initializes the context after all dependencies have been injected. * * @return void */ public function initializeObject() { $this->locale = new Locale('mul_ZZ'); $activeRequestHandler = $this->bootstrap->getActiveRequestHandler(); if ($activeRequestHandler instanceof \TYPO3\FLOW3\Http\HttpRequestHandlerInterface) { $matchingDomains = $this->domainRepository->findByHost($activeRequestHandler->getHttpRequest()->getUri()->getHost()); if (count($matchingDomains) > 0) { $this->currentDomain = $matchingDomains[0]; $this->currentSite = $matchingDomains[0]->getSite(); } else { $this->currentSite = $this->siteRepository->findFirst(); } } else { $this->currentSite = $this->siteRepository->findFirst(); } }