forked from jamescowie/composer-patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
ecf6617
commit 43757e0
Showing
6 changed files
with
220 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Inviqa; | ||
use Inviqa\Patch\Factory; | ||
use Inviqa\Patch\Shell; | ||
|
||
/** | ||
* Checks the validity of the environment before applying the patches. | ||
*/ | ||
class EnvChecker | ||
{ | ||
private $event; | ||
|
||
public function __construct(\Composer\Script\Event $event) | ||
{ | ||
$this->event = $event; | ||
} | ||
|
||
public function check() | ||
{ | ||
$this->clientDeclaredMageRootOnShellPatches(); | ||
} | ||
|
||
private function clientDeclaredMageRootOnShellPatches() | ||
{ | ||
$extra = $this->event->getComposer()->getPackage()->getExtra(); | ||
|
||
if (empty($extra['patches'])) { | ||
return; | ||
} | ||
|
||
$containsShellPatches = false; | ||
|
||
foreach ($extra['patches'] as $patchGroupName => $patchGroup) { | ||
foreach ($patchGroup as $patchName => $patchDetails) { | ||
$patch = Factory::create( | ||
$patchName, | ||
$patchGroupName, | ||
$patchDetails, | ||
array() | ||
); | ||
|
||
if ($patch instanceof Shell) { | ||
$containsShellPatches = true; | ||
break 2; | ||
} | ||
} | ||
} | ||
|
||
if ($containsShellPatches && empty($extra[Patcher::EXTRA_KEY_MAGE_ROOT_DIR])) { | ||
throw new \Exception( | ||
'When using shell patches, you must declare the Mage root using the extra key: ' . | ||
Patcher::EXTRA_KEY_MAGE_ROOT_DIR | ||
); | ||
} | ||
} | ||
} |
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