/** * Determines the current domain and site from the request and sets the resulting values as * as defaults. * * @param array $defaultContextProperties * @return array */ protected function setDefaultSiteAndDomainFromCurrentRequest(array $defaultContextProperties) { $currentDomain = $this->domainRepository->findOneByActiveRequest(); if ($currentDomain !== null) { $defaultContextProperties['currentSite'] = $currentDomain->getSite(); $defaultContextProperties['currentDomain'] = $currentDomain; } else { $defaultContextProperties['currentSite'] = $this->siteRepository->findDefault(); } return $defaultContextProperties; }
/** * @param FinisherContext $finisherContext * @return void * @throws Exception */ public function importSite(FinisherContext $finisherContext) { $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues(); if (isset($formValues['prune']) && intval($formValues['prune']) === 1) { $this->nodeDataRepository->removeAll(); $this->workspaceRepository->removeAll(); $this->domainRepository->removeAll(); $this->siteRepository->removeAll(); $this->persistenceManager->persistAll(); } if (!empty($formValues['packageKey'])) { if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) { throw new Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486); } $packageKey = $formValues['packageKey']; $siteName = $formValues['siteName']; $generatorService = $this->objectManager->get(\Neos\SiteKickstarter\Service\GeneratorService::class); $generatorService->generateSitePackage($packageKey, $siteName); } elseif (!empty($formValues['site'])) { $packageKey = $formValues['site']; } $this->deactivateOtherSitePackages($packageKey); $this->packageManager->activatePackage($packageKey); if (!empty($packageKey)) { try { $contentContext = $this->contextFactory->create(array('workspaceName' => 'live')); $this->siteImportService->importFromPackage($packageKey, $contentContext); } catch (\Exception $exception) { $finisherContext->cancel(); $this->systemLogger->logException($exception); throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864); } } }
/** * Deactivates a domain * * @param Domain $domain Domain to deactivate * @Flow\IgnoreValidation("$domain") * @return void */ public function deactivateDomainAction(Domain $domain) { $domain->setActive(false); $this->domainRepository->update($domain); $this->addFlashMessage('The domain "%s" has been deactivated.', 'Domain deactivated', Message::SEVERITY_OK, array(htmlspecialchars($domain)), 1412373425); $this->unsetLastVisitedNodeAndRedirect('edit', null, null, array('site' => $domain->getSite())); }
/** * Remove given site all nodes for that site and all domains associated. * * @param Site $site * @return void */ public function pruneSite(Site $site) { $siteNodePath = NodePaths::addNodePathSegment(static::SITES_ROOT_PATH, $site->getNodeName()); $this->nodeDataRepository->removeAllInPath($siteNodePath); $siteNodes = $this->nodeDataRepository->findByPath($siteNodePath); foreach ($siteNodes as $siteNode) { $this->nodeDataRepository->remove($siteNode); } $site->setPrimaryDomain(null); $this->siteRepository->update($site); $domainsForSite = $this->domainRepository->findBySite($site); foreach ($domainsForSite as $domain) { $this->domainRepository->remove($domain); } $this->persistenceManager->persistAll(); $this->siteRepository->remove($site); $this->emitSitePruned($site); }
/** * @return void */ public function initializeObject() { $domain = $this->domainRepository->findOneByActiveRequest(); // Set active asset collection to the current site's asset collection, if it has one, on the first view if a matching domain is found if ($domain !== null && !$this->browserState->get('activeAssetCollection') && $this->browserState->get('automaticAssetCollectionSelection') !== true && $domain->getSite()->getAssetCollection() !== null) { $this->browserState->set('activeAssetCollection', $domain->getSite()->getAssetCollection()); $this->browserState->set('automaticAssetCollectionSelection', true); } }
/** * Create a Context for a workspace given by name to be used in this controller. * * @param string $workspaceName Name of the current workspace * @return \Neos\ContentRepository\Domain\Service\Context */ protected function createContext($workspaceName) { $contextProperties = array('workspaceName' => $workspaceName); $currentDomain = $this->domainRepository->findOneByActiveRequest(); if ($currentDomain !== null) { $contextProperties['currentSite'] = $currentDomain->getSite(); $contextProperties['currentDomain'] = $currentDomain; } return $this->contextFactory->create($contextProperties); }
/** * Deactivate a domain record by hostname * * @param string $hostname The hostname to deactivate * @return void */ public function deactivateCommand($hostname) { $domain = $this->domainRepository->findOneByHostname($hostname); if (!$domain instanceof Domain) { $this->outputLine('<error>Domain not found.</error>'); $this->quit(1); } $domain->setActive(false); $this->domainRepository->update($domain); $this->outputLine('Domain entry deactivated.'); }
/** * Default action, displays the login screen * * @param string $username Optional: A username to pre-fill into the username field * @param boolean $unauthorized * @return void */ public function indexAction($username = null, $unauthorized = false) { if ($this->securityContext->getInterceptedRequest() || $unauthorized) { $this->response->setStatus(401); } if ($this->authenticationManager->isAuthenticated()) { $this->redirect('index', 'Backend\\Backend'); } $currentDomain = $this->domainRepository->findOneByActiveRequest(); $currentSite = $currentDomain !== null ? $currentDomain->getSite() : $this->siteRepository->findDefault(); $this->view->assignMultiple(['styles' => array_filter($this->settings['userInterface']['backendLoginForm']['stylesheets']), 'username' => $username, 'site' => $currentSite]); }
/** * @return string */ public function render() { $configuration = array('window.T3Configuration = {};', 'window.T3Configuration.UserInterface = ' . json_encode($this->settings['userInterface']) . ';', 'window.T3Configuration.nodeTypes = {};', 'window.T3Configuration.nodeTypes.groups = ' . json_encode($this->getNodeTypeGroupsSettings()) . ';', 'window.T3Configuration.requirejs = {};', 'window.T3Configuration.neosStaticResourcesBaseUri = ' . json_encode($this->resourceManager->getPublicPackageResourceUri('Neos.Neos', '')) . ';', 'window.T3Configuration.requirejs.paths = ' . json_encode($this->getRequireJsPathMapping()) . ';', 'window.T3Configuration.maximumFileUploadSize = ' . $this->renderMaximumFileUploadSize()); $neosJavaScriptBasePath = $this->getStaticResourceWebBaseUri('resource://Neos.Neos/Public/JavaScript'); $configuration[] = 'window.T3Configuration.neosJavascriptBasePath = ' . json_encode($neosJavaScriptBasePath) . ';'; if ($this->backendAssetsUtility->shouldLoadMinifiedJavascript()) { $configuration[] = 'window.T3Configuration.neosJavascriptVersion = ' . json_encode($this->backendAssetsUtility->getJavascriptBuiltVersion()) . ';'; } if ($this->bootstrap->getContext()->isDevelopment()) { $configuration[] = 'window.T3Configuration.DevelopmentMode = true;'; } if ($activeDomain = $this->domainRepository->findOneByActiveRequest()) { $configuration[] = 'window.T3Configuration.site = "' . $activeDomain->getSite()->getNodeName() . '";'; } return implode("\n", $configuration); }