Makes sure all binaries are on system
@param \Composer\Script\Event $event
@throws Exception
323301
public static function checkBinaries(\Composer\Script\Event $event) {
		foreach (self::$binaries as $cmd) {
			if (!self::commandExists($cmd))
				throw new \Exception('Binary "' . $cmd . '" not found in PATH');

			// $event->getIO()->write($cmd . ' found.');
		}
	}
280915
public static function cleanUpOldModules(Event $event)
    {
        $composer = $event->getComposer();
        $requires = $composer->getPackage()->getRequires();

        $projectPath = str_replace('vendor/vkf/shop', '', $composer->getInstallationManager()->getInstallpath($composer->getPackage()));
        $modulePath = $projectPath . 'htdocs/modules';
        foreach (array('ra', 'vkf') as $renzelVendorDir) {
            foreach (glob($modulePath . '/' . $renzelVendorDir . '/*') as $file) {
                if (is_dir($file)) {
                    $packageId = str_replace($modulePath . '/', '', $file);
                    if (!isset($requires[$packageId])) {
                        self::rmdir($file);
                        $event->getIO()->write('Deleted old package ' . $packageId);
                    }
                }
            }
        }
    }
1017453
public function onAfterInitialise(Event $event): void
    {
        /** @var WebApplication $app */
        $app = $event['app'];

        // Remove index.php
        if ($app->uri->script === 'index.php') {
            $app->uri->script = null;
        }
    }
1225281
public static function installThemesAndFiles(Event $event)
    {
        $syncer = DirectorySyncer::fromEvent($event);

        $syncer->sync('files', 'files');
        $syncer->sync('%vendor%/bolt/themes', 'themes', true, ['base-2016', 'base-2018', 'skeleton']);
    }
22179
public function onPostPackageEvent(PackageEvent $event) {
    // Get the effected package from the Event.
    $installed_package = NULL;
    $operation = $event->getOperation();
    if ($operation instanceof UpdateOperation) {
      $installed_package = $operation->getTargetPackage();
    }
    else {
      $installed_package = $operation->getPackage();
    }
    $package_extra = $installed_package->getExtra();

    // If the effected package has installers, reset cached installers.
    if (isset($package_extra) && isset($package_extra['installer-paths'])) {
      $composer = $event->getComposer();
      $composer->getInstallationManager()->removeInstaller($this->installer);
      $composer->getInstallationManager()->addInstaller($this->installer);
      $this->installer->clearCache();
    }
  }
535131
public function checkCoreDependencies(InstallerEvent $event)
    {
        $options = new Options($this->composer->getPackage()->getExtra());
        $installedCorePackages = array();
        foreach ($event->getInstalledRepo()->getPackages() as $package) {
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                $installedCorePackages[$package->getName()] = $package;
            }
        }

        $operations = array_filter($event->getOperations(), function (OperationInterface $o) {
            return in_array($o->getJobType(), array('install', 'uninstall'));
        });

        foreach ($operations as $operation) {
            $p = $operation->getPackage();
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                switch ($operation->getJobType()) {
                    case "uninstall":
                        unset($installedCorePackages[$p->getName()]);
                        break;
                    case "install":
                        $installedCorePackages[$p->getName()] = $p;
                        break;
                }
            }
        }

        if (count($installedCorePackages) > 1) {
            throw new \RuntimeException("Cannot use more than 1 core package");
        }
    }
710660
public function onPostCmdEvent(\Composer\Script\Event $event)
    {
        if (!empty($this->unsupportedPackages)) {
            $this->io->write(
                '<error>You are using Drupal packages that are not supported by the Drupal Security Team!</error>'
            );
            foreach ($this->unsupportedPackages as $package_name => $package) {
                $extra = $package->getExtra();
                $this->io->write(
                    "  - <comment>$package_name:{$package->getVersion()}</comment>: {$extra['drupal']['security-coverage']['message']}"
                );
            }
            $this->io->write(
                '<comment>See https://www.drupal.org/security-advisory-policy for more information.</comment>'
            );
        }
    }
992524
public function onNewCodeEvent(Event $event)
    {
        $vendorDir   = $event->getComposer()->getConfig()->get('vendor-dir');
        $projectDir  = dirname($vendorDir);
        $phpStormDir = $projectDir . DIRECTORY_SEPARATOR . '.idea';
        $filesDir    = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'files';

        if (is_dir($phpStormDir) && is_dir($filesDir)) {
            $this->patcher->patch(
                new Environment(
                    new Filesystem($phpStormDir),
                    new Filesystem($filesDir),
                    new Filesystem($projectDir),
                    $event->getIO(),
                    $event->getComposer()
                )
            );

            $output = $event->getIO();
            if ($output->isVerbose()) {
                $output->write('Patched the PhpStorm config');
            }
        }
    }
40381
public static function postUpdateAndInstall(Event $event)
    {
        if (!defined('FLOW_PATH_ROOT')) {
            define('FLOW_PATH_ROOT', Files::getUnixStylePath(getcwd()) . '/');
        }

        if (!defined('FLOW_PATH_PACKAGES')) {
            define('FLOW_PATH_PACKAGES', Files::getUnixStylePath(getcwd()) . '/Packages/');
        }

        if (!defined('FLOW_PATH_CONFIGURATION')) {
            define('FLOW_PATH_CONFIGURATION', Files::getUnixStylePath(getcwd()) . '/Configuration/');
        }
        if (!defined('FLOW_PATH_TEMPORARY_BASE')) {
            define('FLOW_PATH_TEMPORARY_BASE', Files::getUnixStylePath(getcwd()) . '/Data/Temporary');
        }

        Files::createDirectoryRecursively('Configuration');
        Files::createDirectoryRecursively('Data');

        Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Essentials', './', false, true);
        Files::copyDirectoryRecursively('Packages/Framework/Neos.Flow/Resources/Private/Installer/Distribution/Defaults', './', true, true);
        $packageManager = new PackageManager(PackageManager::DEFAULT_PACKAGE_INFORMATION_CACHE_FILEPATH, FLOW_PATH_PACKAGES);
        $packageManager->rescanPackages();

        chmod('flow', 0755);
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
162953
public static function execute(Event $event) {
    $io = $event->getIO();

    // Search upwards for a composer.json which depends on Open Social.
    $io->write('Searching for root package...');

    $file = static::getRootPackage();

    $package = $file->read();

    // Add the Asset Packagist repository if it does not already exist.
    if (isset($package['repositories'])) {
      $repository_key = NULL;

      foreach ($package['repositories'] as $key => $repository) {
        if ($repository['type'] == 'composer' && strpos($repository['url'], 'https://asset-packagist.org') === 0) {
          $repository_key = $key;
          break;
        }
      }

      if (is_null($repository_key)) {
        $package['repositories'][] = [
          'type' => 'composer',
          'url' => 'https://asset-packagist.org',
        ];
      }
    }

    // oomphinc/composer-installers-extender is required by Open Social and
    // depends on composer/installers, so it does not need to be specifically
    // included.
    unset(
      $package['require']['oomphinc/composer-installers-extender']
    );

    // Check if we need to add the bower and npm assets to the installer types.
    if (!isset($package['extra']['installer-types']) || !in_array('bower-asset', $package['extra']['installer-types'])) {
      $package['extra']['installer-types'][] = 'bower-asset';
    }
    if (!in_array('npm-asset', $package['extra']['installer-types'])) {
      $package['extra']['installer-types'][] = 'npm-asset';
    }

    // Get root folder based on the location of Drupal core. If we do it in this
    // way we can also support projects that have
    //    $package['extra']['installer-paths']['']
    $root_path = 'html/';
    foreach ($package['extra']['installer-paths'] as $path => $install_type) {
      if (in_array('drupal/core', $install_type, TRUE)) {
        // If Drupal core is installed in the root path we also want the
        // libraries there.
        if ($path == 'core') {
          $root_path = '';
        }
        else {
          $parts = explode('/core', $path);
          if (!empty($parts)) {
            $root_path = $parts[0] . '/';
          }
        }

        break;
      }
    }

    // Add the different library types to the installer paths.
    $package['extra']['installer-paths'][$root_path . 'libraries/{$name}'][] = 'type:drupal-library';
    $package['extra']['installer-paths'][$root_path . 'libraries/{$name}'][] = 'type:bower-asset';
    $package['extra']['installer-paths'][$root_path . 'libraries/{$name}'][] = 'type:npm-asset';

    $file->write($package);
    $io->write('Successfully updated your root composer.json file.');
  }
532339
public function onPostUpdateCmd(Event $event)
    {
        $this->bridgeFactory->createBridge($event->getIO())
            ->update($event->getComposer());
    }
156691
public static function rootInstall(Event $event)
    {
        include getcwd() . '/vendor/autoload.php';

        $io = $event->getIO();

        static::genSecretCode($io);

        static::genSecretConfig($io);

        // Complete
        $io->write('Install complete.');
    }
303804
public static function postInstall(Event $event)
    {
        // initialize the installation directory
        $override = false;
        $installDir = getcwd();

        // check the arguments for an installation directory
        foreach ($event->getArguments() as $arg) {
            // extract arguments
            list ($key, ) = explode('=', $arg);
            // query we want to override files
            if ($key === SetupKeys::ARG_OVERRIDE) {
                $override = true;
            }
            // query for a custom installation directory
            if ($key === SetupKeys::ARG_INSTALL_DIR) {
                $installDir = str_replace("$key=", '', $arg);
            }
        }

        Setup::prepareContext($installDir, $event);

        // process and move the configuration files their target directory
        Setup::processTemplate('etc/appserver/appserver.xml', $override);
        Setup::processTemplate('etc/appserver/appserver-runner.xml', $override);

        // write a message to the console
        $event->getIo()->write(
            sprintf(
                '%s<info>Successfully invoked appserver.io Composer post-install-cmd script ...</info>',
                Setup::$logo
            )
        );
    }
302888
public static function dispatch(\core\event\base $event) {
        if (during_initial_install()) {
            return;
        }
        if (!$event->is_triggered() or $event->is_dispatched()) {
            throw new \coding_exception('Illegal event dispatching attempted.');
        }

        self::$buffer[] = $event;

        if (self::$dispatching) {
            return;
        }

        self::$dispatching = true;
        self::process_buffers();
        self::$dispatching = false;
    }
510188
public static function postAutoloadDump(Event $event)
    {
        $composer = $event->getComposer();
        $config = $composer->getConfig();

        $vendorDir = realpath($config->get('vendor-dir'));

        $packages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
        $pluginsDir = dirname($vendorDir) . DIRECTORY_SEPARATOR . 'plugins';

        $plugins = static::determinePlugins($packages, $pluginsDir, $vendorDir);

        $configFile = static::configFile($vendorDir);
        static::writeConfigFile($configFile, $plugins);
    }
1206219
public function onPostAutoloadDump(Event $event)
    {
        $this->io->writeError('<info>Remove update lock tmp file: ' . $this->getUpdateLockFile() . '</info>');
        if (file_exists($this->getUpdateLockFile())) {
            if (!unlink($this->getUpdateLockFile())) {
                $this->io->writeError("<error>Not removed lock file: " . $this->getUpdateLockFile() . "</error>");
            }
        } else {
            $this->io->writeError("<warning>Not found lock file: " . $this->getUpdateLockFile() . "</warning>");
        }
    }