Issue #2579663 by Mile23, webflo, joshtaylor: Can't use 'composer install' with missing composer.lock and vendor folder
parent
0718153755
commit
db73cab1bd
|
@ -10,6 +10,7 @@ namespace Drupal\Core\Composer;
|
||||||
use Drupal\Component\PhpStorage\FileStorage;
|
use Drupal\Component\PhpStorage\FileStorage;
|
||||||
use Composer\Script\Event;
|
use Composer\Script\Event;
|
||||||
use Composer\Installer\PackageEvent;
|
use Composer\Installer\PackageEvent;
|
||||||
|
use Composer\Semver\Constraint\Constraint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides static functions for composer script events.
|
* Provides static functions for composer script events.
|
||||||
|
@ -71,23 +72,38 @@ class Composer {
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add vendor classes to composers static classmap.
|
* Add vendor classes to Composer's static classmap.
|
||||||
*/
|
*/
|
||||||
public static function preAutoloadDump(Event $event) {
|
public static function preAutoloadDump(Event $event) {
|
||||||
$composer = $event->getComposer();
|
// We need the root package so we can add our classmaps to its loader.
|
||||||
$package = $composer->getPackage();
|
$package = $event->getComposer()->getPackage();
|
||||||
$autoload = $package->getAutoload();
|
// We need the local repository so that we can query and see if it's likely
|
||||||
$autoload['classmap'] = array_merge($autoload['classmap'], array(
|
// that our files are present there.
|
||||||
'vendor/symfony/http-foundation/Request.php',
|
$repository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
|
||||||
'vendor/symfony/http-foundation/ParameterBag.php',
|
// This is, essentially, a null constraint. We only care whether the package
|
||||||
'vendor/symfony/http-foundation/FileBag.php',
|
// is present in vendor/ yet, but findPackage() requires it.
|
||||||
'vendor/symfony/http-foundation/ServerBag.php',
|
$constraint = new Constraint('>', '');
|
||||||
'vendor/symfony/http-foundation/HeaderBag.php',
|
// Check for our packages, and then optimize them if they're present.
|
||||||
'vendor/symfony/http-kernel/HttpKernel.php',
|
if ($repository->findPackage('symfony/http-foundation', $constraint)) {
|
||||||
'vendor/symfony/http-kernel/HttpKernelInterface.php',
|
$autoload = $package->getAutoload();
|
||||||
'vendor/symfony/http-kernel/TerminableInterface.php',
|
$autoload['classmap'] = array_merge($autoload['classmap'], array(
|
||||||
));
|
'vendor/symfony/http-foundation/Request.php',
|
||||||
$package->setAutoload($autoload);
|
'vendor/symfony/http-foundation/ParameterBag.php',
|
||||||
|
'vendor/symfony/http-foundation/FileBag.php',
|
||||||
|
'vendor/symfony/http-foundation/ServerBag.php',
|
||||||
|
'vendor/symfony/http-foundation/HeaderBag.php',
|
||||||
|
));
|
||||||
|
$package->setAutoload($autoload);
|
||||||
|
}
|
||||||
|
if ($repository->findPackage('symfony/http-kernel', $constraint)) {
|
||||||
|
$autoload = $package->getAutoload();
|
||||||
|
$autoload['classmap'] = array_merge($autoload['classmap'], array(
|
||||||
|
'vendor/symfony/http-kernel/HttpKernel.php',
|
||||||
|
'vendor/symfony/http-kernel/HttpKernelInterface.php',
|
||||||
|
'vendor/symfony/http-kernel/TerminableInterface.php',
|
||||||
|
));
|
||||||
|
$package->setAutoload($autoload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue