Skip to content

Commit

Permalink
Merge pull request #212 from cweagans/resolver-capabilities
Browse files Browse the repository at this point in the history
Split out patch resolution into Composer Capabilities
  • Loading branch information
cweagans authored Jun 2, 2018
2 parents 9a31a76 + 53bede9 commit f17c40d
Show file tree
Hide file tree
Showing 20 changed files with 769 additions and 170 deletions.
46 changes: 46 additions & 0 deletions src/Capability/BaseResolverProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace cweagans\Composer\Capability;

use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\Capability\Capability;
use Composer\Plugin\PluginInterface;

abstract class BaseResolverProvider implements Capability, ResolverProvider
{
/**
* @var Composer
*/
protected $composer;

/**
* @var IOInterface
*/
protected $io;

/**
* @var PluginInterface
*/
protected $plugin;

/**
* BaseResolverProvider constructor.
*
* Stores values passed by the plugin manager for later use.
*
* @param array $args
* An array of args passed by the plugin manager.
*/
public function __construct($args)
{
$this->composer = $args['composer'];
$this->io = $args['io'];
$this->plugin = $args['plugin'];
}

/**
* {@inheritDoc}
*/
abstract public function getResolvers();
}
22 changes: 22 additions & 0 deletions src/Capability/CoreResolverProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace cweagans\Composer\Capability;

use cweagans\Composer\Resolvers\DependencyPatches;
use cweagans\Composer\Resolvers\PatchesFile;
use cweagans\Composer\Resolvers\RootComposer;

class CoreResolverProvider extends BaseResolverProvider
{
/**
* {@inheritDoc}
*/
public function getResolvers()
{
return [
new RootComposer($this->composer, $this->io),
new PatchesFile($this->composer, $this->io),
new DependencyPatches($this->composer, $this->io),
];
}
}
22 changes: 22 additions & 0 deletions src/Capability/ResolverProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace cweagans\Composer\Capability;

use Composer\Plugin\Capability\Capability;

/**
* Resolver provider interface.
*
* This capability will receive an array with 'composer' and 'io' keys as
* constructor arguments. It also contains a 'plugin' key containing the
* plugin instance that declared the capability.
*/
interface ResolverProvider extends Capability
{
/**
* Retrieves an array of PatchResolvers.
*
* @return \cweagans\Composer\Resolvers\ResolverBase[]
*/
public function getResolvers();
}
Loading

0 comments on commit f17c40d

Please sign in to comment.