diff --git a/src/Patches.php b/src/Patches.php
index c1851112..e6a211da 100644
--- a/src/Patches.php
+++ b/src/Patches.php
@@ -300,7 +300,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;
}
@@ -344,9 +344,10 @@ protected function getPackageFromOperation(OperationInterface $operation) {
* @param RemoteFilesystem $downloader
* @param $install_path
* @param $patch_url
+ * @param PackageInterface $package
* @throws \Exception
*/
- protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url) {
+ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path, $patch_url, PackageInterface $package) {
// Local patch file.
if (file_exists($patch_url)) {
@@ -366,6 +367,10 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
// it might be useful. p4 is useful for Magento 2 patches
$patch_levels = array('-p1', '-p0', '-p2', '-p4');
+ // Check for specified patch level for this package.
+ if (!empty($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()])){
+ $patch_levels = array($this->composer->getPackage()->getExtra()['patchLevel'][$package->getName()]);
+ }
// Attempt to apply with git apply.
$patched = $this->applyPatchWithGit($install_path, $patch_levels, $filename);