/**
  * @param \Composer\Script\Event $event
  */
 protected function insertComposerModeConstant(\Composer\Script\Event $event)
 {
     $composer = $event->getComposer();
     $pluginConfig = Config::load($composer);
     if (!$pluginConfig->get('composer-mode')) {
         return;
     }
     $composerConfig = $composer->getConfig();
     $vendorDir = $composerConfig->get('vendor-dir');
     $autoloadFile = $vendorDir . '/autoload.php';
     $io = $event->getIO();
     if (!file_exists($autoloadFile)) {
         throw new \RuntimeException(sprintf('Could not adjust autoloader: The file %s was not found.', $autoloadFile));
     }
     $io->write('<info>Inserting TYPO3_COMPOSER_MODE constant</info>');
     $contents = file_get_contents($autoloadFile);
     $constant = "if (!defined('TYPO3_COMPOSER_MODE')) {\n";
     $constant .= "\tdefine('TYPO3_COMPOSER_MODE', TRUE);\n";
     $constant .= "}\n\n";
     // Regex modifiers:
     // "m": \s matches newlines
     // "D": $ matches at EOF only
     // Translation: insert before the last "return" in the file
     $contents = preg_replace('/\\n(?=return [^;]+;\\s*$)/mD', "\n" . $constant, $contents);
     file_put_contents($autoloadFile, $contents);
 }
 /**
  * @return string
  */
 protected function determineInstallPath()
 {
     return $this->pluginConfig->get('cms-package-dir');
 }
 /**
  * @return string
  * @throws \InvalidArgumentException
  */
 public function getContent()
 {
     $includeFileFolder = dirname(dirname(__DIR__)) . '/res/php';
     return $this->filesystem->findShortestPathCode($includeFileFolder, $this->typo3PluginConfig->getBaseDir(), true);
 }
 /**
  * @param CommandEvent $event
  * @return Config
  */
 protected static function getConfig(CommandEvent $event)
 {
     return Config::load($event->getComposer());
 }
 /**
  * Initialize the extension dir based on configuration
  */
 protected function initializeExtensionDir()
 {
     $configDir = $this->filesystem->normalizePath($this->pluginConfig->get('config-dir'));
     $this->extensionDir = $configDir . DIRECTORY_SEPARATOR . self::TYPO3_EXT_DIR;
 }
 /**
  * PluginImplementation constructor.
  *
  * @param Event $event
  * @param IncludeFile $includeFile
  * @param ScriptDispatcher $scriptDispatcher
  */
 public function __construct(Event $event, ScriptDispatcher $scriptDispatcher = null, IncludeFile $includeFile = null)
 {
     $this->event = $event;
     $this->scriptDispatcher = $scriptDispatcher ?: new ScriptDispatcher($event);
     $this->includeFile = $includeFile ?: new IncludeFile($event->getIO(), array(new BaseDirToken($event->getIO(), Typo3PluginConfig::load($event->getComposer())), new WebDirToken($event->getIO(), Typo3PluginConfig::load($event->getComposer())), new ActiveTypo3ExtensionsToken($event->getIO(), $event->getComposer(), Config::load($event->getIO(), $event->getComposer()->getConfig()))), new Filesystem());
 }