Skip to content
Snippets Groups Projects
Commit db73cab1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2579663 by Mile23, webflo, joshtaylor: Can't use 'composer install'...

Issue #2579663 by Mile23, webflo, joshtaylor: Can't use 'composer install' with missing composer.lock and vendor folder
parent 07181537
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -10,6 +10,7 @@
use Drupal\Component\PhpStorage\FileStorage;
use Composer\Script\Event;
use Composer\Installer\PackageEvent;
use Composer\Semver\Constraint\Constraint;
/**
* Provides static functions for composer script events.
......@@ -71,11 +72,19 @@ class Composer {
];
/**
* Add vendor classes to composers static classmap.
* Add vendor classes to Composer's static classmap.
*/
public static function preAutoloadDump(Event $event) {
$composer = $event->getComposer();
$package = $composer->getPackage();
// We need the root package so we can add our classmaps to its loader.
$package = $event->getComposer()->getPackage();
// We need the local repository so that we can query and see if it's likely
// that our files are present there.
$repository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
// This is, essentially, a null constraint. We only care whether the package
// is present in vendor/ yet, but findPackage() requires it.
$constraint = new Constraint('>', '');
// Check for our packages, and then optimize them if they're present.
if ($repository->findPackage('symfony/http-foundation', $constraint)) {
$autoload = $package->getAutoload();
$autoload['classmap'] = array_merge($autoload['classmap'], array(
'vendor/symfony/http-foundation/Request.php',
......@@ -83,12 +92,19 @@ public static function preAutoloadDump(Event $event) {
'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);
}
}
/**
* Ensures that .htaccess and web.config files are present in Composer root.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment