PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.8.1
Defender Security – Malware Scanner, Login Security & Firewall v5.8.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / cweagans / composer-patches / src / Command / RepatchCommand.php

RepatchCommand.php in Defender Security – Malware Scanner, Login Security & Firewall 5.8.1, at vendor/cweagans/composer-patches/src/Command/RepatchCommand.php

65 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace cweagans\Composer\Command;
6
7 use Composer\DependencyResolver\Operation\UninstallOperation;
8 use Symfony\Component\Console\Input\ArrayInput;
9 use Symfony\Component\Console\Input\InputInterface;
10 use Symfony\Component\Console\Output\OutputInterface;
11
12 class RepatchCommand extends PatchesCommandBase
13 {
14 protected function configure(): void
15 {
16 $this->setName('patches-repatch');
17 $this->setDescription('Delete, re-download, and re-patch each dependency with any patches defined.');
18 $this->setAliases(['prp']);
19 }
20
21 protected function execute(InputInterface $input, OutputInterface $output): int
22 {
23 $plugin = $this->getPatchesPluginInstance();
24 if (is_null($plugin)) {
25 return 1;
26 }
27
28 $plugin->loadLockedPatches();
29 $patchCollection = $plugin->getPatchCollection();
30 if (is_null($patchCollection)) {
31 return 1;
32 }
33
34 $localRepository = $this->requireComposer()
35 ->getRepositoryManager()
36 ->getLocalRepository();
37
38 $patched_packages = $patchCollection->getPatchedPackages();
39 $packages = array_filter($localRepository->getPackages(), function ($val) use ($patched_packages) {
40 return in_array($val->getName(), $patched_packages);
41 });
42
43 // Remove patched packages so that we can re-install/re-patch.
44 $promises = [];
45 foreach ($packages as $package) {
46 $uninstallOperation = new UninstallOperation($package);
47 $promises[] = $this->requireComposer()
48 ->getInstallationManager()
49 ->uninstall($localRepository, $uninstallOperation);
50 }
51 // Wait for uninstalls to finish.
52 $promises = array_filter($promises);
53 if (!empty($promises)) {
54 $this->requireComposer()->getLoop()->wait($promises);
55 }
56
57 $input = new ArrayInput(['command' => 'install']);
58 $application = $this->getApplication();
59 $application->setAutoExit(false);
60 $application->run($input, $output);
61
62 return 0;
63 }
64 }
65