Example #1
0
 /**
  * Gather patches from dependencies and store them for later use.
  *
  * @param PackageEvent $event
  */
 public function gatherPatches(PackageEvent $event)
 {
     // If we've already done this, then don't do it again.
     if (isset($this->patches['_patchesGathered'])) {
         return;
     }
     // First, try to get the patches from the root composer.json.
     $extra = $this->composer->getPackage()->getExtra();
     if (isset($extra['patches'])) {
         $this->io->write('<info>Gathering patches for root package.</info>');
         $this->patches = $extra['patches'];
     } else {
         if (isset($extra['patches-file'])) {
             $this->io->write('<info>Gathering patches from patch file.</info>');
             $patches = file_get_contents($extra['patches-file']);
             $patches = json_decode($patches, TRUE);
             if (isset($patches['patches'])) {
                 $this->patches = $patches['patches'];
             }
         } else {
             // @todo: should we throw an exception here?
             return;
         }
     }
     // Now add all the patches from dependencies that will be installed.
     $operations = $event->getOperations();
     $this->io->write('<info>Gathering patches for dependencies. This might take a minute.</info>');
     foreach ($operations as $operation) {
         if ($operation->getJobType() == 'install' || $operation->getJobType() == 'update') {
             $package = $this->getPackageFromOperation($operation);
             $extra = $package->getExtra();
             if (isset($extra['patches'])) {
                 $this->patches = array_merge_recursive($this->patches, $extra['patches']);
             }
         }
     }
     // If we're in verbose mode, list the projects we're going to patch.
     if ($this->io->isVerbose()) {
         foreach ($this->patches as $package => $patches) {
             $number = count($patches);
             $this->io->write('<info>Found ' . $number . ' patches for ' . $package . '.</info>');
         }
     }
     // Make sure we don't gather patches again. Extra keys in $this->patches
     // won't hurt anything, so we'll just stash it there.
     $this->patches['_patchesGathered'] = TRUE;
 }
Example #2
0
 /**
  * Gather patches from dependencies and store them for later use.
  *
  * @param PackageEvent $event
  */
 public function gatherPatches(PackageEvent $event)
 {
     // If we've already done this, then don't do it again.
     if (isset($this->patches['_patchesGathered'])) {
         return;
     } elseif (!$this->isPatchingEnabled()) {
         return;
     }
     $this->patches = $this->grabPatches();
     if (empty($this->patches)) {
         $this->io->write('<info>No patches supplied.</info>');
     }
     $extra = $this->composer->getPackage()->getExtra();
     $patches_ignore = isset($extra['patches-ignore']) ? $extra['patches-ignore'] : [];
     // Now add all the patches from dependencies that will be installed.
     $operations = $event->getOperations();
     $this->io->write('<info>Gathering patches for dependencies. This might take a minute.</info>');
     foreach ($operations as $operation) {
         if ($operation->getJobType() == 'install' || $operation->getJobType() == 'update') {
             $package = $this->getPackageFromOperation($operation);
             $extra = $package->getExtra();
             if (isset($extra['patches'])) {
                 if (isset($patches_ignore[$package->getName()])) {
                     foreach ($patches_ignore[$package->getName()] as $package => $patches) {
                         if (isset($extra['patches'][$package])) {
                             $extra['patches'][$package] = array_diff($extra['patches'][$package], $patches);
                         }
                     }
                 }
                 $this->patches = array_merge_recursive($this->patches, $extra['patches']);
             }
             // Unset installed patches for this package
             if (isset($this->installedPatches[$package->getName()])) {
                 unset($this->installedPatches[$package->getName()]);
             }
         }
     }
     // Merge installed patches from dependencies that did not receive an update.
     foreach ($this->installedPatches as $patches) {
         $this->patches = array_merge_recursive($this->patches, $patches);
     }
     // If we're in verbose mode, list the projects we're going to patch.
     if ($this->io->isVerbose()) {
         foreach ($this->patches as $package => $patches) {
             $number = count($patches);
             $this->io->write('<info>Found ' . $number . ' patches for ' . $package . '.</info>');
         }
     }
     // Make sure we don't gather patches again. Extra keys in $this->patches
     // won't hurt anything, so we'll just stash it there.
     $this->patches['_patchesGathered'] = TRUE;
 }
 /**
  * Gather patches from dependencies and store them for later use.
  *
  * @param PackageEvent $event
  */
 public function gatherPatches(PackageEvent $event)
 {
     // If we've already done this, then don't do it again.
     if (isset($this->patches['_patchesGathered'])) {
         return;
     }
     $this->patches = $this->grabPatches();
     if ($this->patches == FALSE) {
         $this->io->write('<info>No patches supplied.</info>');
         return;
     }
     // Now add all the patches from dependencies that will be installed.
     $operations = $event->getOperations();
     $this->io->write('<info>Gathering patches for dependencies. This might take a minute.</info>');
     foreach ($operations as $operation) {
         if ($operation->getJobType() == 'install' || $operation->getJobType() == 'update') {
             $package = $this->getPackageFromOperation($operation);
             $extra = $package->getExtra();
             if (isset($extra['patches'])) {
                 $this->patches = array_merge_recursive($this->patches, $extra['patches']);
             }
         }
     }
     // If we're in verbose mode, list the projects we're going to patch.
     if ($this->io->isVerbose()) {
         foreach ($this->patches as $package => $patches) {
             $number = count($patches);
             $this->io->write('<info>Found ' . $number . ' patches for ' . $package . '.</info>');
         }
     }
     // Make sure we don't gather patches again. Extra keys in $this->patches
     // won't hurt anything, so we'll just stash it there.
     $this->patches['_patchesGathered'] = TRUE;
 }