Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out patch resolution into Composer Capabilities #212

Merged
merged 17 commits into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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