mirror of
https://github.com/flarum/core.git
synced 2025-07-18 15:21:16 +02:00
Add compatiblity with Composer 2.0
- The structure of vendor/composer/installed.json will change. - The same file will now contain the relative path to package locations. References: - https://github.com/composer/composer/blob/master/UPGRADE-2.0.md - https://php.watch/articles/composer-2
This commit is contained in:
@@ -73,12 +73,20 @@ class ExtensionManager
|
|||||||
// Load all packages installed by composer.
|
// Load all packages installed by composer.
|
||||||
$installed = json_decode($this->filesystem->get($this->app->vendorPath().'/composer/installed.json'), true);
|
$installed = json_decode($this->filesystem->get($this->app->vendorPath().'/composer/installed.json'), true);
|
||||||
|
|
||||||
|
// Composer 2.0 changes the structure of the installed.json manifest
|
||||||
|
$installed = $installed['packages'] ?? $installed;
|
||||||
|
|
||||||
foreach ($installed as $package) {
|
foreach ($installed as $package) {
|
||||||
if (Arr::get($package, 'type') != 'flarum-extension' || empty(Arr::get($package, 'name'))) {
|
if (Arr::get($package, 'type') != 'flarum-extension' || empty(Arr::get($package, 'name'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$path = isset($package['install-path'])
|
||||||
|
? $this->getExtensionsDir().'/composer/'.$package['install-path']
|
||||||
|
: $this->getExtensionsDir().'/'.Arr::get($package, 'name');
|
||||||
|
|
||||||
// Instantiates an Extension object using the package path and composer.json file.
|
// Instantiates an Extension object using the package path and composer.json file.
|
||||||
$extension = new Extension($this->getExtensionsDir().'/'.Arr::get($package, 'name'), $package);
|
$extension = new Extension($path, $package);
|
||||||
|
|
||||||
// Per default all extensions are installed if they are registered in composer.
|
// Per default all extensions are installed if they are registered in composer.
|
||||||
$extension->setInstalled(true);
|
$extension->setInstalled(true);
|
||||||
|
@@ -89,14 +89,22 @@ class EnableBundledExtensions implements Step
|
|||||||
private function loadExtensions()
|
private function loadExtensions()
|
||||||
{
|
{
|
||||||
$json = file_get_contents("$this->vendorPath/composer/installed.json");
|
$json = file_get_contents("$this->vendorPath/composer/installed.json");
|
||||||
|
$installed = json_decode($json, true);
|
||||||
|
|
||||||
return (new Collection(json_decode($json, true)))
|
// Composer 2.0 changes the structure of the installed.json manifest
|
||||||
|
$installed = $installed['packages'] ?? $installed;
|
||||||
|
|
||||||
|
return (new Collection($installed))
|
||||||
->filter(function ($package) {
|
->filter(function ($package) {
|
||||||
return Arr::get($package, 'type') == 'flarum-extension';
|
return Arr::get($package, 'type') == 'flarum-extension';
|
||||||
})->filter(function ($package) {
|
})->filter(function ($package) {
|
||||||
return ! empty(Arr::get($package, 'name'));
|
return ! empty(Arr::get($package, 'name'));
|
||||||
})->map(function ($package) {
|
})->map(function ($package) {
|
||||||
$extension = new Extension($this->vendorPath.'/'.Arr::get($package, 'name'), $package);
|
$path = isset($package['install-path'])
|
||||||
|
? "$this->vendorPath/composer/".$package['install-path']
|
||||||
|
: $this->vendorPath.'/'.Arr::get($package, 'name');
|
||||||
|
|
||||||
|
$extension = new Extension($path, $package);
|
||||||
$extension->setVersion(Arr::get($package, 'version'));
|
$extension->setVersion(Arr::get($package, 'version'));
|
||||||
|
|
||||||
return $extension;
|
return $extension;
|
||||||
|
Reference in New Issue
Block a user