Skip to content

Commit e3f1774

Browse files
author
catch
committed
Issue #3284420 by longwave, Gábor Hojtsy, Spokje: Remove Composer 1 specific code paths from Drupal 10
(cherry picked from commit 6c6f6a3f31d7df657c32d634c9fa8fdf4723ae9a)
1 parent 5743333 commit e3f1774

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

AllowedPackages.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Drupal\Composer\Plugin\Scaffold;
44

55
use Composer\Composer;
6-
use Composer\DependencyResolver\Operation\OperationInterface;
76
use Composer\Installer\PackageEvent;
87
use Composer\IO\IOInterface;
98
use Composer\Package\PackageInterface;
@@ -101,8 +100,7 @@ public function event(PackageEvent $event) {
101100
// which of the newly-installed packages have scaffold operations, and
102101
// whether or not they are allowed to scaffold by the allowed-packages
103102
// option in the root-level composer.json file.
104-
$operationType = $this->getOperationType($operation);
105-
$package = $operationType === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
103+
$package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
106104
if (ScaffoldOptions::hasOptions($package->getExtra())) {
107105
$this->newPackages[$package->getName()] = $package;
108106
}
@@ -181,26 +179,6 @@ protected function evaluateNewPackages(array $allowed_packages) {
181179
return $allowed_packages;
182180
}
183181

184-
/**
185-
* Determine the type of the provided operation.
186-
*
187-
* Adjusts API used for Composer 1 or Composer 2.
188-
*
189-
* @param \Composer\DependencyResolver\Operation\OperationInterface $operation
190-
* The operation object.
191-
*
192-
* @return string
193-
* The operation type.
194-
*/
195-
protected function getOperationType(OperationInterface $operation) {
196-
// Use Composer 2 method.
197-
if (method_exists($operation, 'getOperationType')) {
198-
return $operation->getOperationType();
199-
}
200-
// Fallback to Composer 1 method.
201-
return $operation->getJobType();
202-
}
203-
204182
/**
205183
* Retrieves a package from the current composer process.
206184
*

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"homepage": "https://www.drupal.org/project/drupal",
77
"license": "GPL-2.0-or-later",
88
"require": {
9-
"composer-plugin-api": "^1 || ^2",
9+
"composer-plugin-api": "^2",
1010
"php": ">=7.3.0"
1111
},
1212
"conflict": {

0 commit comments

Comments
 (0)