1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 02:31:17 +02:00

Give Extenders information about which Extension they belong to

This commit is contained in:
Toby Zerner
2018-03-04 10:13:12 +10:30
parent e8d915850d
commit 2967b5d106
7 changed files with 27 additions and 18 deletions

View File

@@ -284,20 +284,23 @@ class ExtensionManager
return $this->getEnabledExtensions()
->flatMap(function (Extension $extension) {
$bootstrapper = $extension->getBootstrapperPath();
if ($this->filesystem->exists($bootstrapper)) {
return (array) require $bootstrapper;
} else {
return [];
}
})->map(function ($extender) {
// If an extension has not yet switched to the new bootstrap.php
// format, it might return a function (or more of them). We wrap
// these in a Compat extender to enjoy an unique interface.
if ($extender instanceof \Closure || is_string($extender)) {
return new Compat($extender);
} else {
return $extender;
return array_map(function ($extender) use ($extension) {
// If an extension has not yet switched to the new bootstrap.php
// format, it might return a function (or more of them). We wrap
// these in a Compat extender to enjoy an unique interface.
if ($extender instanceof \Closure || is_string($extender)) {
$extender = new Compat($extender);
}
return function ($app) use ($extension, $extender) {
return $extender($app, $extension);
};
}, array_flatten((array) require $bootstrapper));
}
return [];
});
}