-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
236 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Vaimo Group. All rights reserved. | ||
* See LICENSE_VAIMO.txt for license details. | ||
*/ | ||
namespace Vaimo\ComposerPatches\Factories; | ||
|
||
use Vaimo\ComposerPatches\Repository\ResetsResolvers; | ||
use Vaimo\ComposerPatches\Patch\PackageResolvers; | ||
use Vaimo\ComposerPatches\Config as Config; | ||
|
||
class QueueGeneratorFactory | ||
{ | ||
/** | ||
* @var \Composer\Composer | ||
*/ | ||
private $composer; | ||
|
||
/** | ||
* @param \Composer\Composer $composer | ||
*/ | ||
public function __construct( | ||
\Composer\Composer $composer | ||
) { | ||
$this->composer = $composer; | ||
} | ||
|
||
public function create(Config $pluginConfig, array $filters = array(), $resets = array()) | ||
{ | ||
$rootPackage = $this->composer->getPackage(); | ||
|
||
$packageCollector = new \Vaimo\ComposerPatches\Package\Collector(array($rootPackage)); | ||
|
||
$resolvers = array( | ||
'full' => new PackageResolvers\FullResetResolver(), | ||
'missing' => new PackageResolvers\MissingPatchesResolver() | ||
); | ||
|
||
$repositoryAnalyser = new \Vaimo\ComposerPatches\Repository\Analyser( | ||
$packageCollector, | ||
$resolvers[$pluginConfig->shouldResetEverything() ? 'full' : 'missing'] | ||
); | ||
|
||
$missingItemsAnalyser = new \Vaimo\ComposerPatches\Repository\Analyser( | ||
$packageCollector, | ||
$resolvers['missing'] | ||
); | ||
|
||
$resetsResolvers = array( | ||
'direct' => new ResetsResolvers\DirectResetsResolver($missingItemsAnalyser), | ||
'related' => new ResetsResolvers\RelatedResetsResolver($repositoryAnalyser) | ||
); | ||
|
||
$listResolver = new \Vaimo\ComposerPatches\Repository\PatchesApplier\ListResolver( | ||
$repositoryAnalyser, | ||
$missingItemsAnalyser | ||
); | ||
|
||
return new \Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator( | ||
$listResolver, | ||
!$resets | ||
? $resetsResolvers | ||
: array_intersect_key($resetsResolvers, array_flip($resets)), | ||
$filters | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Copyright © Vaimo Group. All rights reserved. | ||
* See LICENSE_VAIMO.txt for license details. | ||
*/ | ||
namespace Vaimo\ComposerPatches\Interfaces; | ||
|
||
use Composer\Repository\WritableRepositoryInterface as PackageRepository; | ||
|
||
interface PatchesResetsResolverInterface | ||
{ | ||
/** | ||
* @param PackageRepository $repository | ||
* @param array $patches | ||
* @param array $filters | ||
* @return array | ||
*/ | ||
public function resolvePatchesResets(PackageRepository $repository, array $patches, array $filters); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Copyright © Vaimo Group. All rights reserved. | ||
* See LICENSE_VAIMO.txt for license details. | ||
*/ | ||
namespace Vaimo\ComposerPatches\Repository\ResetsResolvers; | ||
|
||
use Composer\Repository\WritableRepositoryInterface as PackageRepository; | ||
|
||
class DirectResetsResolver implements \Vaimo\ComposerPatches\Interfaces\PatchesResetsResolverInterface | ||
{ | ||
/** | ||
* @var \Vaimo\ComposerPatches\Repository\Analyser | ||
*/ | ||
private $itemsAnalyser; | ||
|
||
/** | ||
* @param \Vaimo\ComposerPatches\Repository\Analyser $itemsAnalyser | ||
*/ | ||
public function __construct( | ||
\Vaimo\ComposerPatches\Repository\Analyser $itemsAnalyser | ||
) { | ||
$this->itemsAnalyser = $itemsAnalyser; | ||
} | ||
|
||
public function resolvePatchesResets(PackageRepository $repository, array $patches, array $filters) | ||
{ | ||
return array_keys( | ||
$this->itemsAnalyser->determinePackageResets($repository, $patches) | ||
); | ||
} | ||
} |
Oops, something went wrong.