diff --git a/src/Patches.php b/src/Patches.php
index 0c5e9589..dd5502e2 100644
--- a/src/Patches.php
+++ b/src/Patches.php
@@ -289,7 +289,7 @@ public function postInstall(PackageEvent $event) {
$this->io->write(' ' . $url . ' (' . $description. ')');
try {
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::PRE_PATCH_APPLY, $package, $url, $description));
- $this->getAndApplyPatch($downloader, $install_path, $url);
+ $this->getAndApplyPatch($downloader, $install_path, $url, $package);
$this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $url, $description));
$extra['patches_applied'][$description] = $url;
}
@@ -333,9 +333,10 @@ protected function getPackageFromOperation(OperationInterface $operation) {
* @param RemoteFilesystem $downloader
* @param $install_path
* @param $patch_url
+ * @param $package
* @throws \Exception
*/
- protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url) {
+ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, $package) {
// Local patch file.
if (file_exists($patch_url)) {
@@ -356,6 +357,9 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
// p0 is next likely. p2 is extremely unlikely, but for some special cases,
// it might be useful.
$patch_levels = array('-p1', '-p0', '-p2');
+ if(!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])){
+ $patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
+ }
foreach ($patch_levels as $patch_level) {
$checked = $this->executeCommand('cd %s && GIT_DIR=. git apply --check %s %s', $install_path, $patch_level, $filename);
if ($checked) {