コード例 #1
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;
         }
     }
 }
コード例 #2
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));
     }
 }