コード例 #1
0
 /**
  * Called from composer
  *
  * @param CommandEvent $event
  * @return void
  */
 public static function setupConsole(CommandEvent $event)
 {
     $config = self::getConfig($event);
     $installDir = self::getInstallDir($config);
     $filesystem = new Filesystem();
     if ($event->getComposer()->getPackage()->getName() === 'helhum/typo3-console') {
         $extDir = $installDir . 'typo3conf/ext/';
         $consoleDir = $extDir . 'typo3_console';
         if (!file_exists($consoleDir)) {
             $filesystem->ensureDirectoryExists($extDir);
             $filesystem->symlink($config->getBaseDir(), $consoleDir);
         }
     }
     $scriptName = self::isWindowsOs() ? 'typo3cms.bat' : 'typo3cms';
     $success = self::safeCopy($scriptName, $installDir);
     if (!$success) {
         $event->getIO()->write(sprintf(self::COPY_FAILED_MESSAGE_TITLE, $scriptName));
         $event->getIO()->write(sprintf(self::COPY_FAILED_MESSAGE, $scriptName));
     }
 }
コード例 #2
0
 /**
  * @param \Composer\Script\Event $event
  */
 public function linkAutoloader(\Composer\Script\Event $event)
 {
     $composer = $event->getComposer();
     $composerConfig = $composer->getConfig();
     $localRepository = $composer->getRepositoryManager()->getLocalRepository();
     foreach ($localRepository->getCanonicalPackages() as $package) {
         if ($package->getType() === 'typo3-cms-core') {
             $defaultVendorDir = \Composer\Config::$defaultConfig['vendor-dir'];
             $packagePath = $composer->getInstallationManager()->getInstallPath($package);
             $jsonFile = new \Composer\Json\JsonFile($packagePath . DIRECTORY_SEPARATOR . 'composer.json', new \Composer\Util\RemoteFilesystem($event->getIO()));
             $packageJson = $jsonFile->read();
             $packageVendorDir = !empty($packageJson['config']['vendor-dir']) ? $this->filesystem->normalizePath($packageJson['config']['vendor-dir']) : $defaultVendorDir;
             $autoloaderSourceDir = $composerConfig->get('vendor-dir');
             $autoloaderTargetDir = $packagePath . DIRECTORY_SEPARATOR . $packageVendorDir;
             $autoloaderFileName = 'autoload.php';
             $this->filesystem->ensureDirectoryExists($autoloaderTargetDir);
             $this->filesystem->remove($autoloaderTargetDir . DIRECTORY_SEPARATOR . $autoloaderFileName);
             try {
                 $this->filesystem->symlink($autoloaderSourceDir . DIRECTORY_SEPARATOR . $autoloaderFileName, $autoloaderTargetDir . DIRECTORY_SEPARATOR . $autoloaderFileName, FALSE, TRUE);
             } catch (\RuntimeException $e) {
                 if ($e->getCode() !== 1430494084) {
                     throw $e;
                 }
                 $code = array('<?php', 'return require ' . $this->filesystem->findShortestPathCode($autoloaderTargetDir . DIRECTORY_SEPARATOR . $autoloaderFileName, $autoloaderSourceDir . DIRECTORY_SEPARATOR . $autoloaderFileName) . ';');
                 file_put_contents($autoloaderTargetDir . DIRECTORY_SEPARATOR . $autoloaderFileName, implode(chr(10), $code));
             }
             $this->insertComposerModeConstant($event);
             break;
         }
     }
 }
コード例 #3
0
 /**
  * @param \Composer\Package\PackageInterface $initial
  * @param \Composer\Package\PackageInterface $target
  */
 protected function updateCode(\Composer\Package\PackageInterface $initial, \Composer\Package\PackageInterface $target)
 {
     // Currently the install path for all versions is the same.
     // In the future the install path for two core versions may differ.
     $initialDownloadPath = $this->getInstallPath($initial);
     $targetDownloadPath = $this->getInstallPath($target);
     if ($targetDownloadPath !== $initialDownloadPath) {
         // if the target and initial dirs intersect, we force a remove + install
         // to avoid the rename wiping the target dir as part of the initial dir cleanup
         if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath) {
             $this->removeCode($initial);
             $this->installCode($target);
             return;
         }
         $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
     }
     $this->downloadManager->update($initial, $target, $targetDownloadPath);
 }