/** * Action for deleting an existing package * * @param string $packageKey The package key of the package to create * @return string */ public function deleteAction($packageKey) { if ($packageKey === '') { return $this->helpAction(); } if (!$this->packageManager->isPackageAvailable($packageKey)) { return 'The package "' . $packageKey . '" does not exist.' . PHP_EOL; } $this->packageManager->deletePackage($packageKey); return 'Package "' . $packageKey . '" has been deleted.' . PHP_EOL; }
/** * Evaluates the absolute path and filename of the resource file specified * by the given path. * * @param string $requestedPath * @param boolean $checkForExistence Whether a (non-hash) path should be checked for existence before being returned * @return mixed The full path and filename or FALSE if the file doesn't exist * @throws \TYPO3\FLOW3\Resource\Exception * @throws \InvalidArgumentException */ protected function evaluateResourcePath($requestedPath, $checkForExistence = TRUE) { if (substr($requestedPath, 0, strlen(self::SCHEME)) !== self::SCHEME) { throw new \InvalidArgumentException('The ' . __CLASS__ . ' only supports the \'' . self::SCHEME . '\' scheme.', 1256052544); } $uriParts = parse_url($requestedPath); if (!is_array($uriParts) || !isset($uriParts['host'])) { return FALSE; } if (strlen($uriParts['host']) === 40) { $resourcePath = $this->resourceManager->getPersistentResourcesStorageBaseUri() . $uriParts['host']; if ($checkForExistence === FALSE || file_exists($resourcePath)) { return $resourcePath; } else { return FALSE; } } if (!$this->packageManager->isPackageAvailable($uriParts['host'])) { throw new \TYPO3\FLOW3\Resource\Exception(sprintf('Invalid resource URI "%s": Package "%s" is not available.', $requestedPath, $uriParts['host']), 1309269952); } $package = $this->packageManager->getPackage($uriParts['host']); $resourcePath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($package->getResourcesPath(), $uriParts['path'])); if ($checkForExistence === FALSE || file_exists($resourcePath)) { return $resourcePath; } return FALSE; }
/** * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext * @return void * @throws \TYPO3\Setup\Exception */ public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext) { $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues(); if (isset($formValues['prune']) && intval($formValues['prune']) === 1) { $this->nodeRepository->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 \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486); } $packageKey = $formValues['packageKey']; $siteName = $formValues['packageKey']; $this->packageManager->createPackage($packageKey, NULL, Files::getUnixStylePath(Files::concatenatePaths(array(FLOW3_PATH_PACKAGES, 'Sites')))); $this->generatorService->generateSitesXml($packageKey, $siteName); $this->generatorService->generateSitesTypoScript($packageKey, $siteName); $this->generatorService->generateSitesTemplate($packageKey, $siteName); $this->packageManager->activatePackage($packageKey); } else { $packageKey = $formValues['site']; } if ($packageKey !== '') { try { $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext('live'); $this->nodeRepository->setContext($contentContext); $this->siteImportService->importFromPackage($packageKey); } catch (\Exception $exception) { $finisherContext->cancel(); $this->flashMessageContainer->addMessage(new \TYPO3\FLOW3\Error\Error(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()))); } } }
/** * @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); } }
/** * Refreeze a package * * Refreezes a currently frozen package: all precompiled information is removed * and file monitoring will consider the package exactly once, on the next * request. After that request, the package remains frozen again, just with the * updated data. * * By specifying <b>all</b> as a package key, all currently frozen packages are * refrozen (the default). * * @param string $packageKey Key of the package to refreeze, or 'all' * @return void * @see typo3.flow3:package:freeze * @see typo3.flow3:cache:flush */ public function refreezeCommand($packageKey = 'all') { if (!$this->bootstrap->getContext()->isDevelopment()) { $this->outputLine('Package freezing is only supported in Development context.'); $this->quit(3); } $packagesToRefreeze = array(); if ($packageKey === 'all') { foreach (array_keys($this->packageManager->getAvailablePackages()) as $packageKey) { if ($this->packageManager->isPackageFrozen($packageKey)) { $packagesToRefreeze[] = $packageKey; } } if ($packagesToRefreeze === array()) { $this->outputLine('Nothing to do, no packages were frozen.'); $this->quit(0); } } else { if ($packageKey === NULL) { $this->outputLine('You must specify a package to refreeze.'); $this->quit(1); } if (!$this->packageManager->isPackageAvailable($packageKey)) { $this->outputLine('Package "%s" is not available.', array($packageKey)); $this->quit(2); } if (!$this->packageManager->isPackageFrozen($packageKey)) { $this->outputLine('Package "%s" was not frozen.', array($packageKey)); $this->quit(0); } $packagesToRefreeze = array($packageKey); } foreach ($packagesToRefreeze as $packageKey) { $this->packageManager->refreezePackage($packageKey); $this->outputLine('Refroze package "%s".', array($packageKey)); } Scripts::executeCommand('typo3.flow3:cache:flush', $this->settings, FALSE); $this->sendAndExit(0); }