Apply plugin modifications to Composer

@param Composer $composer
@param IOInterface $io
327713
public function activate(Composer $composer, IOInterface $io)
    {
        $this->io = $io;
        $this->composer = $composer;
        $rootDir = realpath($this->composer->getConfig()->get('vendor-dir') . '/../');
        $settings = $this->composer->getPackage()->getExtra()['application'] ?? [];
        $this->appInfo = new AppInfo($rootDir, $settings);
        $this->isProject = $composer->getPackage()->getType() === 'project';

        if ($this->isProject) {
            $this->packageInstaller = new PackageInstaller($this->appInfo, $io, $composer);
            $this->composer
                ->getInstallationManager()
                ->addInstaller($this->packageInstaller);
        }
    }
299611
private static function validateProject(IOInterface $io, string $projectRoot)
    {
        $jsonFile = $projectRoot . '/composer.json';
        $lockFile = $projectRoot . '/composer.lock';

        if (file_exists($lockFile)) {
            $io->writeError('Detected composer.lock. Aborting initialization of MCP Panthor.');
            return false;
        }

        $composerFile = json_decode(file_get_contents($jsonFile), true);

        $name = $composerFile['name'] ?? '';
        if ($name !== 'ql/mcp-panthor') {
            $io->writeError('MCP Panthor not detected. Something may have gone wrong during \'composer create-project\'.');
            return false;
        }

        return true;
    }
892457
public function addPlugin(PluginInterface $plugin)
    {
        if ($this->io->isDebug()) {
            $this->io->writeError('Loading plugin '.get_class($plugin));
        }
        $this->plugins[] =  $plugin;
        $plugin->activate($this->composer, $this->io);

        if ($plugin instanceof EventSubscriberInterface) {
            $this->composer->getEventDispatcher()->addSubscriber($plugin);
        }
    }
238049
public static function build(Composer $composer, array $defaults = array(), $io = null)
    {
        $config = self::getConfigBase($composer, $io);

        return new Config($config, $defaults);
    }
145492
protected function removeComposerAuthorInformation( InputInterface $input, OutputInterface $output ) {
		$command = $this->getApplication()->find( 'install:clean-composer' );

		$output->write( '<comment>Cleaning <info>composer.json</info> ...</comment>' );

		$command->run( new ArrayInput( [
			'command' => 'install:carbon-fields',
		] ), new NullOutput() );

		$output->writeln( ' <info>Done</info>' );
	}
863464
protected function writeComposerFile($composer)
    {
        file_put_contents(
            $this->command->path.'/composer.json',
            json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
        );
    }
1305292
public function uninstall(Composer $composer, IOInterface $io, $pluginName)
    {
        $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName);
        
        if ($plugin) {
            $result = $this->wp(function () use ($plugin) {
                return uninstall_plugin($plugin);
            });
            
            $this->succeeded(__FUNCTION__, $pluginName, $result === true || $result === null);
        }
    }
24071
protected function execute(InputInterface $input, OutputInterface $output) : void
    {
        $io     = $this->getIO($input, $output);
        $config = $this->getConfig($input->getOption('configuration'));

        $configurator = new Creator($io, $config);
        $configurator->force($input->getOption('force'))
                     ->extend($input->getOption('extend'))
                     ->advanced($input->getOption('advanced'))
                     ->run();
    }
717758
public static function configure(IOInterface $io, PhpCsFixer $phpCsFixer)
    {
        if (true === $phpCsFixer->isUndefined()) {
            $answer = $io->ask(HookQuestions::PHPCSFIXER_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);

            $phpCsFixer = $phpCsFixer
                ->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));

            if (true === $phpCsFixer->isEnabled()) {
                $psr0Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR0_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
                $psr1Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR1_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
                $psr2Answer = $io->ask(HookQuestions::PHPCSFIXER_PSR2_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);
                $symfonyAnswer = $io->ask(HookQuestions::PHPCSFIXER_SYMFONY_LEVEL, HookQuestions::DEFAULT_TOOL_ANSWER);

                $phpCsFixer = $phpCsFixer->addLevels(new PhpCsFixerLevels(
                    new Level(HookQuestions::DEFAULT_TOOL_ANSWER ===  strtoupper($psr0Answer)),
                    new Level(HookQuestions::DEFAULT_TOOL_ANSWER ===  strtoupper($psr1Answer)),
                    new Level(HookQuestions::DEFAULT_TOOL_ANSWER ===  strtoupper($psr2Answer)),
                    new Level(HookQuestions::DEFAULT_TOOL_ANSWER ===  strtoupper($symfonyAnswer))
                ));
            }

            $optionsAnswer = $io->ask(HookQuestions::PHPCSFIXER_OPTIONS, null);
            $options = new PhpCsFixerOptions($optionsAnswer);
            $phpCsFixer = $phpCsFixer->setOptions($options);
        }

        return $phpCsFixer;
    }
1215137
public function activate(Composer $composer, IOInterface $io)
    {
        if (!Util::isJoomla() && !Util::isJoomlatoolsPlatform()) {
            throw new \RuntimeException('Working directory is not a valid Joomla installation');
        }

        $this->_composer = $composer;
        $this->_io = $io;

        $credentials = $this->_composer->getConfig()->get('joomla');

        if(is_null($credentials) || !is_array($credentials)) {
            $credentials = array();
        }

        $bootstrapper = Bootstrapper::getInstance();
        $bootstrapper->setIO($this->_io);
        $bootstrapper->setCredentials($credentials);

        $installer = new ComposerInstaller($this->_io, $this->_composer);
        $composer->getInstallationManager()->addInstaller($installer);
    }
1329671
public function create(Composer $composer): ViolationFilterInterface
    {
        $chain = new ViolationFilterChain(
            ...array_merge(
                $this->getSuggestsFilters($composer),
                $this->getIgnoreFilters($composer)
            )
        );

        return new ViolationFilterChain(
            $chain,
            new PackageRequirementsFilter(
                $composer->getLocker(),
                $chain
            )
        );
    }
263620
public function handle(Composer $composer)
    {
        $output = new OperationFileOutput($this->outputFileName);

        $composer->run($output, $this->extensionsNames);
    }
1218486
public function configureComposerJson(Event $event)
    {
        static::$plugin->getInstanceOf(ComposerConfigurator::class)->configure($event->getComposer(), $event->getIO());
    }
68184
public static function build(Composer $composer, $io = null)
    {
        $config = self::getConfigBase($composer, $io);
        $config = self::injectDeprecatedConfig($config, (array) $composer->getPackage()->getExtra());

        return new Config($config);
    }
324683
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($root = $input->getArgument('root-dir')) {
            chdir(realpath($root));
        }

        $rootDir = realpath(getcwd());
        $logger  = new ConsoleLogger($output);

        $composerJson = $rootDir . '/composer.json';
        if (!file_exists($composerJson)) {
            $logger->error(
                '<error>File not found, can not analyze: {file}</error> ',
                array('file' => $composerJson)
            );

            return 1;
        }

        $destinations   = array();
        $destinations[] = new PsrLogDestination($logger);

        $report   = $this->prepareReport($input, $logger);
        $composer = json_decode(file_get_contents($composerJson), true);
        $ignore   = $this->getIgnoredFiles($composer, $input->getOption('ignore-files'));
        $factory  = new AutoloadValidatorFactory($rootDir, new ClassMapGenerator($ignore), $report);
        $test     = new AutoloadValidator($factory->createFromComposerJson($composer), $report);
        $test->validate();
        if ($report->hasError()) {
            $logger->error('<error>Testing loaders found errors</error> ');
        }

        $enumLoader = new EnumeratingClassLoader();
        $this->prepareLoader($enumLoader, $test);

        $hacker = new HackPreparator($enumLoader, $logger);
        if ($custom = $input->getOption('add-autoloader')) {
            $hacker->prepareHacks(
                $custom,
                array(
                    $rootDir,
                    dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'hacks'
                )
            );
        }
        $this->prepareComposerFallbackLoader($enumLoader, $rootDir, $composer);
        if (!($input->getOption('disable-legacy-hacks') || $input->getOption('add-autoloader'))) {
            $hacker->prepareLegacyHack();
        }

        $loadCycle = new AllLoadingAutoLoader($enumLoader, $test->getClassMap(), $logger);

        return static::$exitCodes[$loadCycle->run() && !$report->hasError()];
    }
874391
private static function getComposerHome(Composer $composer)
    {
        return null !== $composer->getConfig() && $composer->getConfig()->has('home')
            ? $composer->getConfig()->get('home')
            : '';
    }
986162
public function compose( ViewInterface $view ) {
		$composers = $this->getComposersForView( $view->getName() );

		foreach ( $composers as $composer ) {
			$composer->execute( $view );
		}
	}