/** * Add a domain record * * @param string $siteNodeName The nodeName of the site rootNode, e.g. "phoenixtypo3org" * @param string $hostPattern The host pattern to match on, e.g. "phoenix.typo3.org" * @return void */ public function addCommand($siteNodeName, $hostPattern) { $site = $this->siteRepository->findOneByNodeName($siteNodeName); if (!$site instanceof Site) { $this->outputLine('No site found with nodeName "%s".', array($siteNodeName)); $this->quit(1); } $domains = $this->domainRepository->findByHostPattern($hostPattern); if ($domains->count() > 0) { $this->outputLine('The host pattern "%s" is not unique', array($hostPattern)); $this->quit(1); } $domain = new Domain(); $domain->setSite($site); $domain->setHostPattern($hostPattern); $this->domainRepository->add($domain); $this->outputLine('Domain created'); }
/** * @param string $workspaceName * @return void * @todo Pagination * @todo Tree filtering + level limit * @todo Search field * @todo Difference mechanism */ public function indexAction($workspaceName = NULL) { if (is_null($workspaceName)) { $workspaceName = $this->securityContext->getParty()->getPreferences()->get('context.workspace'); } $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext($workspaceName); $contentContext->setInvisibleContentShown(TRUE); $contentContext->setRemovedContentShown(TRUE); $contentContext->setInaccessibleContentShown(TRUE); $this->nodeRepository->setContext($contentContext); $sites = array(); foreach ($this->workspacesService->getUnpublishedNodes($workspaceName) as $node) { if (!$node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Section')) { $pathParts = explode('/', $node->getPath()); if (count($pathParts) > 2) { $siteNodeName = $pathParts[2]; $folder = $this->findFolderNode($node); $folderPath = implode('/', array_slice(explode('/', $folder->getPath()), 3)); $relativePath = str_replace(sprintf('/sites/%s/%s', $siteNodeName, $folderPath), '', $node->getPath()); if (!isset($sites[$siteNodeName]['siteNode'])) { $sites[$siteNodeName]['siteNode'] = $this->siteRepository->findOneByNodeName($siteNodeName); } $sites[$siteNodeName]['folders'][$folderPath]['folderNode'] = $folder; $change = array('node' => $node); if ($node->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:AbstractNode')) { $change['configuration'] = $node->getContentType()->getConfiguration(); } $sites[$siteNodeName]['folders'][$folderPath]['changes'][$relativePath] = $change; } } } $liveWorkspace = $this->workspacesService->getWorkspace('live'); ksort($sites); foreach ($sites as $siteKey => $site) { foreach ($site['folders'] as $folderKey => $folder) { foreach ($folder['changes'] as $changeKey => $change) { $liveNode = $this->nodeRepository->findOneByIdentifier($change['node']->getIdentifier(), $liveWorkspace); $sites[$siteKey]['folders'][$folderKey]['changes'][$changeKey]['isNew'] = is_null($liveNode); $sites[$siteKey]['folders'][$folderKey]['changes'][$changeKey]['isMoved'] = $liveNode && $change['node']->getPath() !== $liveNode->getPath(); } } ksort($sites[$siteKey]['folders']); } $workspaces = array(); foreach ($this->workspacesService->getWorkspaces() as $workspace) { array_push($workspaces, array('workspaceNode' => $workspace, 'unpublishedNodesCount' => $this->workspacesService->getUnpublishedNodesCount($workspace->getName()))); } $this->view->assignMultiple(array('workspaceName' => $workspaceName, 'workspaces' => $workspaces, 'sites' => $sites)); }
/** * @param string $pathAndFilename * @return void * @throws \TYPO3\FLOW3\Package\Exception\UnknownPackageException * @throws \TYPO3\FLOW3\Package\Exception\InvalidPackageStateException */ public function importSitesFromFile($pathAndFilename) { $contentContext = $this->nodeRepository->getContext(); $contentContext->setInvisibleContentShown(TRUE); $contentContext->setInaccessibleContentShown(TRUE); // no file_get_contents here because it does not work on php://stdin $fp = fopen($pathAndFilename, 'rb'); $xmlString = ''; while (!feof($fp)) { $xmlString .= fread($fp, 4096); } fclose($fp); $xml = new \SimpleXMLElement($xmlString); foreach ($xml->site as $siteXml) { $site = $this->siteRepository->findOneByNodeName((string) $siteXml['nodeName']); if ($site === NULL) { $site = new \TYPO3\TYPO3\Domain\Model\Site((string) $siteXml['nodeName']); $this->siteRepository->add($site); } else { $this->siteRepository->update($site); } $site->setName((string) $siteXml->properties->name); $site->setState((int) $siteXml->properties->state); $siteResourcesPackageKey = (string) $siteXml->properties->siteResourcesPackageKey; if ($this->packageManager->isPackageAvailable($siteResourcesPackageKey) === FALSE) { throw new \TYPO3\FLOW3\Package\Exception\UnknownPackageException('Package "' . $siteResourcesPackageKey . '" specified in the XML as site resources package does not exist.', 1303891443); } if ($this->packageManager->isPackageActive($siteResourcesPackageKey) === FALSE) { throw new \TYPO3\FLOW3\Package\Exception\InvalidPackageStateException('Package "' . $siteResourcesPackageKey . '" specified in the XML as site resources package is not active.', 1303898135); } $site->setSiteResourcesPackageKey($siteResourcesPackageKey); $rootNode = $contentContext->getWorkspace()->getRootNode(); if ($rootNode->getNode('/sites') === NULL) { $rootNode->createSingleNode('sites'); } $siteNode = $rootNode->getNode('/sites/' . $site->getNodeName()); if ($siteNode === NULL) { $siteNode = $rootNode->getNode('/sites')->createSingleNode($site->getNodeName()); } $siteNode->setContentObject($site); $this->parseNodes($siteXml, $siteNode); } }