phabel/src/Composer/Plugin.php

70 lines
1.7 KiB
PHP
Raw Normal View History

2020-08-13 18:30:12 +02:00
<?php
namespace Phabel\Composer;
use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\Installer\InstallerEvent;
use Composer\Installer\InstallerEvents;
2020-11-01 20:44:11 +01:00
use Composer\Installer\PackageEvent;
use Composer\Installer\PackageEvents;
2020-08-13 18:30:12 +02:00
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
/**
* @author Daniil Gentili <daniil@daniil.it>
* @license MIT
*/
class Plugin implements PluginInterface, EventSubscriberInterface
{
/**
* IO interface.
*/
private IOInterface $io;
/**
* Apply plugin modifications to Composer.
*
* @param Composer $composer Composer instance
* @param IOInterface $io IO instance
*
* @return void
*/
public function activate(Composer $composer, IOInterface $io): void
{
$repoManager = $composer->getRepositoryManager();
$repos = $repoManager->getRepositories();
2020-11-01 20:44:11 +01:00
$repoManager->prependRepository(new Repository($repos[0]));
2020-08-13 18:30:12 +02:00
$this->io = $io;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
InstallerEvents::PRE_DEPENDENCIES_SOLVING =>
['onDependencySolve', 100000],
2020-11-01 20:44:11 +01:00
PackageEvents::POST_PACKAGE_INSTALL =>
['onInstall', 100000],
2020-08-13 18:30:12 +02:00
];
}
2020-11-01 20:44:11 +01:00
public function onInstall(PackageEvent $event): void
{
var_dumP($event);
}
2020-08-13 18:30:12 +02:00
/**
2020-08-23 20:54:56 +02:00
* Emitted before composer solves dependencies.
2020-08-13 18:30:12 +02:00
*
* @param InstallerEvent $event Event
2020-08-23 20:54:56 +02:00
*
2020-08-13 18:30:12 +02:00
* @return void
*/
public function onDependencySolve(InstallerEvent $event): void
{
2020-08-23 20:54:56 +02:00
\var_dump($event);
2020-08-13 18:30:12 +02:00
}
}