The activation method is called when the plugin is activated.

@param Composer    $composer
@param IOInterface $io
433296
public function activate(Composer $composer, IOInterface $io)
    {
        /** composer and io properties are assgned for convenience */
        $this->composer = $composer;
        $this->io = $io;
    }
280577
public function activate(Composer $composer, IOInterface $io)
    {
        $this->composer = $composer;
        $this->io = $io;
        if(isset($this->composer->getPackage()->getExtra()['auto-require']['vendor-name'])) {
            $this->vendorName = $this->composer->getPackage()->getExtra()['auto-require']['vendor-name'];
        } else {
            $this->vendorName = 'yourpackage';
        }
        if(isset($this->composer->getPackage()->getExtra()['auto-require']['path-scheme'])) {
            $this->pathScheme = $this->composer->getPackage()->getExtra()['auto-require']['path-scheme'];
        } else {
            $this->pathScheme = '{vendorName}/{vendorName}.{name}';
        }
    }
984915
public function setComposer($composer)
    {
        ObjectHelper::isInstanceOf($author, [Organization::class, PersonInterface::class]);
        
        $this->_composer = $composer;
        return $this;
    }
187899
public static function addInstallers(Config $config, Composer $composer, IOInterface $io)
    {
        $im = $composer->getInstallationManager();

        $im->addInstaller(new BowerInstaller($config, $io, $composer, Assets::createType('bower')));
        $im->addInstaller(new AssetInstaller($config, $io, $composer, Assets::createType('npm')));
    }
539999
protected function prepare($action, Composer $composer, IOInterface $io, $pluginName)
    {
        $this->composer = $composer;
        $this->io = $io;
        
        if ($this->isPluginExcluded($action, $pluginName)) {
            return $this->excluded($action, $pluginName) && false;
        }
        
        $plugin = $this->getPlugin($pluginName);
        
        if (! $plugin) {
            return $this->failed($action, $pluginName) && false;
        }
        
        $this->executing($action, $pluginName);
        
        return $plugin;
    }
980225
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setIO($input, $output);
        parent::doRun($input, $output);
    }
986162
public function compose( ViewInterface $view ) {
		$composers = $this->getComposersForView( $view->getName() );

		foreach ( $composers as $composer ) {
			$composer->execute( $view );
		}
	}
1063154
public function activate(Composer $composer, IOInterface $io)
    {
        $package = $composer->getPackage();

        if ($package instanceof CompletePackage) {
            $this->addScriptsTo($package);
        }

        if ($package instanceof RootPackageInterface) {
            $this->addAutoloadTo($package);
        }
    }
426005
public static function fromComposer(IOInterface $io)
    {
        $input = new ArrayInput([]);
        $input->setInteractive($io->isInteractive());

        if ($io instanceof ConsoleIO) {
            $ref = new \ReflectionProperty($io, 'output');
            $ref->setAccessible(true);
            $output = $ref->getValue($io);
            if ($output instanceof ConsoleOutputInterface) {
                $output = $output->getErrorOutput();
            }
        } else {
            $output = new NullOutput();
        }

        return new static($input, $output);
    }
810489
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $context = Context::createDefaultContext();
        $plugins = $this->prepareExecution(self::LIFECYCLE_METHOD, $io, $input, $context);

        $keepUserData = (bool) $input->getOption('keep-user-data');

        $uninstalledPluginCount = 0;
        /** @var PluginEntity $plugin */
        foreach ($plugins as $plugin) {
            if ($plugin->getInstalledAt() === null) {
                $io->note(sprintf('Plugin "%s" is not installed. Skipping.', $plugin->getName()));

                continue;
            }

            $this->pluginLifecycleService->uninstallPlugin($plugin, $context, $keepUserData);
            ++$uninstalledPluginCount;

            $io->text(sprintf('Plugin "%s" has been uninstalled successfully.', $plugin->getName()));
        }

        if ($uninstalledPluginCount !== 0) {
            $io->success(sprintf('Uninstalled %d plugins.', $uninstalledPluginCount));
        }
    }
611935
public function activate(Processor $processor, $type, $id)
    {
        return $processor->activate($this, $type, $id);
    }
1130745
public function activate(Composer $composer, IOInterface $io) {
    $this->composer = $composer;
    $this->io = $io;
    $this->eventDispatcher = $composer->getEventDispatcher();
    ProcessExecutor::setTimeout(3600);
    $this->executor = new ProcessExecutor($this->io);
  }
386555
protected function executeClear(ContainerInterface $container, IoInterface $inOut): void
    {
        assert($inOut);

        $appConfig     = $this->getApplicationConfiguration($container);
        $cacheCallable = $appConfig[ApplicationConfigurationInterface::KEY_CACHE_CALLABLE];
        assert(is_string($cacheCallable));

        // if exists
        if (is_callable($cacheCallable) === true) {
            // location of the cache file
            $path = (new ReflectionMethod($cacheCallable))->getDeclaringClass()->getFileName();

            $fileSystem = $this->getFileSystem($container);
            if ($fileSystem->exists($path) === true) {
                $fileSystem->delete($path);
                $inOut->writeInfo("Cache file deleted `$path`." . PHP_EOL, IoInterface::VERBOSITY_VERBOSE);

                return;
            }
        }

        $inOut->writeInfo('Cache already clean.' . PHP_EOL);
    }
103692
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;

        // For verbose mode we want to output all informational and above
        // messages to the symphony output interface.
        if ($input->hasOption('verbose') && $input->getOption('verbose')) {
            $this->logger->pushHandler(
                new OutputLogHandler($this->output, Logger::INFO)
            );
        }

        // Allow PHPCI to run in "debug mode"
        if ($input->hasOption('debug') && $input->getOption('debug')) {
            $output->writeln('<comment>Debug mode enabled.</comment>');
            define('PHPCI_DEBUG_MODE', true);
        }

        $running = $this->validateRunningBuilds();

        $this->logger->pushProcessor(new LoggedBuildContextTidier());
        $this->logger->addInfo(Lang::get('finding_builds'));
        $store = Factory::getStore('Build');
        $result = $store->getByStatus(0, $this->maxBuilds);
        $this->logger->addInfo(Lang::get('found_n_builds', count($result['items'])));

        $builds = 0;

        while (count($result['items'])) {
            $build = array_shift($result['items']);
            $build = BuildFactory::getBuild($build);

            // Skip build (for now) if there's already a build running in that project:
            if (!$this->isFromDaemon && in_array($build->getProjectId(), $running)) {
                $this->logger->addInfo(Lang::get('skipping_build', $build->getId()));
                $result['items'][] = $build;

                // Re-run build validator:
                $running = $this->validateRunningBuilds();
                continue;
            }

            $builds++;

            try {
                // Logging relevant to this build should be stored
                // against the build itself.
                $buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
                $this->logger->pushHandler($buildDbLog);

                $builder = new Builder($build, $this->logger);
                $builder->execute();

                // After execution we no longer want to record the information
                // back to this specific build so the handler should be removed.
                $this->logger->popHandler($buildDbLog);
            } catch (\Exception $ex) {
                $build->setStatus(Build::STATUS_FAILED);
                $build->setFinished(new \DateTime());
                $build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
                $store->save($build);
            }

        }

        $this->logger->addInfo(Lang::get('finished_processing_builds'));

        return $builds;
    }
26804
public function update(Composer $composer)
    {
        $this->io->write(
            '<info>Updating NPM dependencies for root project</info>'
        );

        $package = $composer->getPackage();

        if ($this->isDependantPackage($package, true)) {
            $timeout = $this->packageTimeout($package->getExtra());

            $this->client->update(null, $timeout);
            $this->client->install(null, true, $timeout);
        } else {
            $this->io->write('Nothing to update');
        }

        $this->installForVendors($composer);
    }
688604
public function install(IOInterface $io)
    {
        foreach ($this->mappingReader as $mapping) {
            if (file_exists($mapping->getDestination())) {
                continue;
            }

            $this->installFile($mapping);

            $io->write(
                sprintf(
                    '<info>Installed:</info> %s',
                    $mapping->getRelativeDestination()
                )
            );
        }
    }
997720
private static function write(IOInterface $io, string $message)
    {
        $msg = [
            '[Panthor]: ' . $message,
        ];

        $io->write($msg);
    }