/** * @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; } } }
/** * Initialize symlinks with configuration */ protected function initializeSymlinks() { $webDir = $this->filesystem->normalizePath($this->pluginConfig->get('web-dir')); $this->filesystem->ensureDirectoryExists($webDir); $backendDir = $this->filesystem->normalizePath($this->pluginConfig->get('backend-dir')); $sourcesDir = $this->determineInstallPath(); $this->symlinks = array($sourcesDir . DIRECTORY_SEPARATOR . self::TYPO3_INDEX_PHP => $webDir . DIRECTORY_SEPARATOR . self::TYPO3_INDEX_PHP, $sourcesDir . DIRECTORY_SEPARATOR . self::TYPO3_DIR => $backendDir); }