コード例 #1
0
 /**
  * @return void
  */
 public function indexAction()
 {
     $packageGroups = array();
     foreach ($this->packageManager->getAvailablePackages() as $package) {
         $packageGroup = current(array_slice(explode('/', $package->getPackagePath()), -3, 1));
         $packageGroups[$packageGroup][$package->getPackageKey()] = array('sanitizedPackageKey' => str_replace('.', '', $package->getPackageKey()), 'version' => $package->getPackageMetaData()->getVersion(), 'title' => $package->getPackageMetaData()->getTitle(), 'description' => $package->getPackageMetaData()->getDescription(), 'metaData' => $package->getPackageMetaData(), 'isActive' => $this->packageManager->isPackageActive($package->getPackageKey()), 'isFrozen' => $this->packageManager->isPackageFrozen($package->getPackageKey()), 'isProtected' => $package->isProtected());
     }
     ksort($packageGroups);
     foreach (array_keys($packageGroups) as $packageGroup) {
         ksort($packageGroups[$packageGroup]);
     }
     $this->view->assignMultiple(array('packageGroups' => $packageGroups, 'isDevelopmentContext' => $this->objectManager->getContext()->isDevelopment()));
 }
コード例 #2
0
 /**
  * Generates a new migration file and returns the path to it.
  *
  * If $diffAgainstCurrent is TRUE, it generates a migration file with the
  * diff between current DB structure and the found mapping metadata.
  *
  * Otherwise an empty migration skeleton is generated.
  *
  * @param boolean $diffAgainstCurrent
  * @return string Path to the new file
  */
 public function generateAndExecutePartialMigrationFor($tables = array(), $package = null, $diffAgainstCurrent = TRUE)
 {
     $configuration = $this->getMigrationConfiguration();
     $up = NULL;
     $down = NULL;
     if ($diffAgainstCurrent === TRUE) {
         $connection = $this->entityManager->getConnection();
         $platform = $connection->getDatabasePlatform();
         $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
         if (empty($metadata)) {
             return 'No mapping information to process.';
         }
         $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
         $fromSchema = $connection->getSchemaManager()->createSchema();
         $toSchema = $tool->getSchemaFromMetadata($metadata);
         $fromSchema = $this->filterSchema($fromSchema, $tables);
         $toSchema = $this->filterSchema($toSchema, $tables);
         $up = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform));
         $down = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform));
         if (!$up && !$down) {
             return 'No changes detected in your mapping information.';
         }
     }
     if (!is_null($package) && $this->packageManager->isPackageActive($package)) {
         $package = $this->packageManager->getPackage($package);
         $migrationsPath = $package->getPackagePath() . "Migrations/" . ucfirst($platform->getName()) . "/";
         $configuration->setMigrationsDirectory($migrationsPath);
     }
     $migrationFile = $this->writeMigrationClassToFile($configuration, $up, $down);
     preg_match("/Version([0-9]+)\\.php/", $migrationFile, $matches);
     $version = $matches[1];
     $this->executeMigration($version);
 }
コード例 #3
0
 /**
  * Action for deactivating a package
  *
  * @param string $packageKey The package key of the package to create
  * @return string
  */
 public function deactivateAction($packageKey)
 {
     if ($packageKey === '') {
         return $this->helpAction();
     }
     if (!$this->packageManager->isPackageActive($packageKey)) {
         return 'Package "' . $packageKey . '" was not active.' . PHP_EOL;
     }
     $this->packageManager->deactivatePackage($packageKey);
     return 'Package "' . $packageKey . '" deactivated.' . PHP_EOL;
 }
コード例 #4
0
 /**
  * @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);
     }
 }
コード例 #5
0
 /**
  * Freeze a package
  *
  * This function marks a package as <b>frozen</b> in order to improve performance
  * in a development context. While a package is frozen, any modification of files
  * within that package won't be tracked and can lead to unexpected behavior.
  *
  * File monitoring won't consider the given package. Further more, reflection
  * data for classes contained in the package is cached persistently and loaded
  * directly on the first request after caches have been flushed. The precompiled
  * reflection data is stored in the <b>Configuration</b> directory of the
  * respective package.
  *
  * By specifying <b>all</b> as a package key, all currently frozen packages are
  * frozen (the default).
  *
  * @param string $packageKey Key of the package to freeze
  * @return void
  * @see typo3.flow3:package:unfreeze
  * @see typo3.flow3:package:refreeze
  */
 public function freezeCommand($packageKey = 'all')
 {
     if (!$this->bootstrap->getContext()->isDevelopment()) {
         $this->outputLine('Package freezing is only supported in Development context.');
         $this->quit(3);
     }
     $packagesToFreeze = array();
     if ($packageKey === 'all') {
         foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) {
             if (!$this->packageManager->isPackageFrozen($packageKey)) {
                 $packagesToFreeze[] = $packageKey;
             }
         }
         if ($packagesToFreeze === array()) {
             $this->outputLine('Nothing to do, all active packages were already frozen.');
             $this->quit(0);
         }
     } elseif ($packageKey === 'blackberry') {
         $this->outputLine('http://bit.ly/freeze-blackberry');
         $this->quit(42);
     } else {
         if (!$this->packageManager->isPackageActive($packageKey)) {
             if ($this->packageManager->isPackageAvailable($packageKey)) {
                 $this->outputLine('Package "%s" is not active and thus cannot be frozen.', array($packageKey));
                 $this->quit(1);
             } else {
                 $this->outputLine('Package "%s" is not available.', array($packageKey));
                 $this->quit(2);
             }
         }
         if ($this->packageManager->isPackageFrozen($packageKey)) {
             $this->outputLine('Package "%s" was already frozen.', array($packageKey));
             $this->quit(0);
         }
         $packagesToFreeze = array($packageKey);
     }
     foreach ($packagesToFreeze as $packageKey) {
         $this->packageManager->freezePackage($packageKey);
         $this->outputLine('Froze package "%s".', array($packageKey));
     }
 }