Main entry point for command.

@param \Composer\Script\Event $event
Composer event.

@throws \RuntimeException
480794
public static function execute(Event $event) {
    $composer = $event->getComposer();
    $encoder = new IniEncoder();

    // Convert the lock file to a make file using Drush's make-convert command.
    $binDir = $composer->getConfig()->get('bin-dir');
    $make = NULL;
    $executor = new ProcessExecutor();
    $executor->execute($binDir . '/drush make-convert composer.lock', $make);
    $make = Yaml::parse($make);

    // Include any drupal-library packages in the make file.
    $libraries = $composer
      ->getRepositoryManager()
      ->getLocalRepository()
      ->getPackages();
    $libraries = array_filter($libraries, function (PackageInterface $package) {
      return $package->getType() === 'drupal-library';
    });

    // Drop the vendor prefixes.
    foreach ($libraries as $library) {
      $oldKey = $library->getName();
      $newKey = basename($oldKey);
      $make['libraries'][$newKey] = $make['libraries'][$oldKey];
      unset($make['libraries'][$oldKey]);
    }

    // Check for any asset library overrides and apply if so. Also drop the
    // vendor name from the library.
    if (array_key_exists('libraries', $make)) {
      /** @var array[] $overrides */
      $overrides = $composer->getPackage()->getExtra();

      if (array_key_exists(static::ASSET_OVERRIDE_PROP, $overrides)) {
        /** @var array $override */
        foreach ($overrides[static::ASSET_OVERRIDE_PROP] as $libraryName => $override) {
          // Skip unsupported packages.
          if (!array_key_exists($libraryName, $make['libraries'])) {
            continue;
          }

          // Remove excluded packages.
          if (array_key_exists('exclude', $override) && $override['exclude'] === TRUE) {
            unset($make['libraries'][$libraryName]);
            continue;
          }

          // If a key doesn't exist, generate one by stripping out the vendor
          // prefix.
          $key = basename($libraryName);
          if (array_key_exists('key', $override)) {
            $key = $override['key'];
            unset($override['key']);
          }

          $makeDef = $make['libraries'][$libraryName];
          unset($make['libraries'][$libraryName]);
          $make['libraries'][$key] = $makeDef;

          // Apply all overrides.
          foreach ($override as $overrideKey => $overrideValue) {
            $make['libraries'][$key][$overrideKey] = $overrideValue;
          }
        }
      }
    }

    if (isset($make['projects']['drupal'])) {
      // Always use drupal.org's core repository, or patches will not apply.
      $make['projects']['drupal']['download']['url'] = 'https://git.drupal.org/project/drupal.git';
      $core = [
        'api' => 2,
        'core' => '8.x',
        'projects' => [
          'drupal' => [
            'type' => 'core',
            'version' => $make['projects']['drupal']['download']['tag'],
          ],
        ],
      ];
      if (isset($make['projects']['drupal']['patch'])) {
        $core['projects']['drupal']['patch'] = $make['projects']['drupal']['patch'];
      }
      file_put_contents('drupal-org-core.make', $encoder->encode($core));
      unset($make['projects']['drupal']);
    }

    foreach ($make['projects'] as &$project) {
      if ($project['download']['type'] === 'git') {
        if (!array_key_exists('tag', $project['download'])) {
          $tag = "{$project['download']['branch']}-dev";
        }
        else {
          $tag = $project['download']['tag'];
          preg_match('/\d+\.x-\d+\.0/', $tag, $match);
          $tag = str_replace($match, str_replace('x-', NULL, $match), $tag);
          preg_match('/\d+\.\d+\.0/', $tag, $match);
          $tag = str_replace($match, substr($match[0], 0, -2), $tag);
        }

        $project['version'] = $tag;
        unset($project['download']);
      }
    }
    unset($project);

    file_put_contents('drupal-org.make', $encoder->encode($make));
  }
993129
public function startup(Event $event)
    {
        $controller = $event->subject();
        if (!empty($controller->request->data) && !Configure::read('DataPreparation.notrimRequestData')) {
            $controller->request->data = $this->_trimDeep($controller->request->data);
        }
        if (!empty($controller->request->query) && !Configure::read('DataPreparation.notrimRequestQuery')) {
            $controller->request->query = $this->_trimDeep($controller->request->query);
        }
        if (!empty($controller->request->params['pass']) && !Configure::read('DataPreparation.notrimRequestParams')) {
            $controller->request->params['pass'] = $this->_trimDeep($controller->request->params['pass']);
        }
    }
375158
public function add($event) {
        $event->setParent($this->_parent);
        $this->_events[$event->getName()] = $event;
    }
587333
public static function configureProject(Event $event)
    {
        DirectoryConfigurator::fromEvent($event)->run();
        BundleConfigurator::fromEvent($event)->run();

        // Install assets here since they they were skipped above
        static::installAssets($event, false);
    }
841920
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // add the configured extractors to the internal array
            /** @var \AppserverIo\Appserver\Core\Api\Node\ExtractorNodeInterface $extractorNode */
            foreach ($applicationServer->getSystemConfiguration()->getExtractors() as $extractorNode) {
                /** @var \AppserverIo\Appserver\Core\Extractors\ExtractorFactoryInterface $extractorFactory */
                $extractorFactory = $extractorNode->getFactory();

                // use the factory if available
                /** @var \AppserverIo\Appserver\Core\Interfaces\ConsoleInterface $console */
                $extractor = $extractorFactory::factory($applicationServer, $extractorNode);

                // deploy the found application archives
                $extractor->deployWebapps();

                // log that the extractor has successfully been initialized and executed
                $applicationServer->getSystemLogger()->debug(
                    sprintf('Extractor %s successfully initialized and executed', $extractorNode->getName())
                );
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
284078
public function handle(EventInterface $event)
    {

        try {
            // load the application server and the naming directory instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // deploy the applications for all containers
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */
            foreach ($applicationServer->getSystemConfiguration()->getContainers() as $containerNode) {
                // load the container instance to deploy the applications for
                /** @var \AppserverIo\Psr\ApplicationServer\ContainerInterface $container */
                $container = $namingDirectory->search(
                    sprintf(
                        'php:services/%s/%s',
                        $applicationServer->runlevelToString(ApplicationServerInterface::NETWORK),
                        $containerNode->getName()
                    )
                );

                // load the containers deployment
                /** @var \AppserverIo\Psr\Deployment\DeploymentInterface $deployment */
                $deployment = $container->getDeployment();
                $deployment->injectContainer($container);

                // deploy and initialize the container's applications
                $deployment->deploy();
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
669784
private function runFirstInstall(ScriptEvent $event)
    {
        $installer    = Installer::create(
            $event->getIO(),
            // Create a new Composer instance to ensure full processing of the merged files.
            Factory::create($event->getIO(), null, false)
        );

        $installer->setPreferSource($this->isPreferredInstall('source'));
        $installer->setPreferDist($this->isPreferredInstall('dist'));
        $installer->setDevMode($event->isDevMode());
        $installer->setDumpAutoloader($this->state->shouldDumpAutoloader());
        $installer->setOptimizeAutoloader($this->state->shouldOptimizeAutoloader());

        if ($this->state->forceUpdate()) {
            // Force update mode so that new packages are processed rather than just telling
            // the user that composer.json and composer.lock don't match.
            $installer->setUpdate(true);
        }

        $installer->run();
    }
408556
public static function setup(Event $event)
    {
        $consoleDir = ComposerHelper::getConsoleDir();
        if (null === $consoleDir) {
            throw new \RuntimeException('Console not found');
        }

        /* Doctrine Migrations */
        if (true === class_exists(DoctrineMigrationsBundle::class)) {
            ComposerHelper::write($event, 'DoctrineMigrationsBundle exist. Start migrations.');

            ComposerHelper::executeCommand($event, $consoleDir, 'doctrine:migrations:migrate', 600);
        }
    }
1219731
public function main()
    {
        $commandLine = $this->prepareCommandLine();
        $this->log("Executing " . $commandLine);
        passthru($commandLine, $returnCode);

        if ($returnCode > 0) {
            throw new BuildException("Composer execution failed");
        }
    }
1127704
public function run(ScriptEvent $event): bool
    {
        if (!$this->shouldRun($event)) {
            return true;
        }
        $io = $event->getIO();
        $io->writeError('');
        $io->writeError('<info>Setting up TYPO3</info>');

        $this->initializeCompatibilityLayer($event);
        $consoleIO = new ConsoleIo($io);

        $setup = new InstallActionDispatcher(
            new ConsoleOutput($consoleIO->getOutput(), $consoleIO->getInput()),
            CommandDispatcher::createFromComposerRun()
        );
        $setup->dispatch([]);

        $io->writeError('');
        $io->writeError('<info>Your TYPO3 installation is now ready to use.</info>');

        $localRepository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
        $serverCommandPackage = $localRepository->findPackage('typo3-console/php-server-command', new EmptyConstraint());
        if ($serverCommandPackage !== null) {
            $io->writeError('');
            $io->writeError(sprintf('<info>Run</info> <comment>%s server:run</comment> <info>in your project root directory, to start the PHP builtin web server.</info>', substr($event->getComposer()->getConfig()->get('bin-dir') . '/typo3cms', strlen(getcwd()) + 1)));
        }

        return true;
    }
1345179
public function onCommand(CommandEvent $event)
    {
        switch ($event->getCommandName()) {
            case 'dump-autoload':
                $_this = new DumpAutoloadEventHandler(
                    $this->__installer->getComposer()->getPackage(),
                    $this->__installer->getComposer()
                );
                break;
            default: break;
        }
    }
826734
public function runEvent($event)
    {
        $this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
        $event->run($this->laravel);
        $this->eventsRan = true;
    }
155240
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // load the service instance and prepare the filesystem
            /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */
            $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService');
            $service->prepareFileSystem();

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
1071294
private static function runUpdateProjectFromAssets(Event $event)
    {
        if ($event->getName() !== ScriptEvents::POST_UPDATE_CMD) {
            return;
        }

        $updater = new ScriptHandlerUpdater($event);

        if (!$updater->needsUpdate()) {
            return;
        }
        $updater->update();

        static::updateProject($event);
    }
947632
public function handle(Event $event)
    {
        $name = $event->getName();
        list(, $method) = explode('.', $name);
        if (empty($this->_config['for']) && empty($this->_config['when'])) {
            return $this->{$method}($event);
        }
        if ($this->matches($event)) {
            return $this->{$method}($event);
        }
    }
119168
public function runHandler(Event $event)
    {
        if (is_callable($this->handler)) {
            return call_user_func($this->handler, $event);
        }
        return false;
    }
485387
public function handle($event)
    {
        $method = $this->getMethodFor($event);

        if (method_exists($this, $method)) {
            return call_user_func([$this, $method], $event);
        }
    }