- Merged
This commit is contained in:
1 parent
a9db9cd846
commit
45ffc6e128
7 files changed
+53
-11
No files matched your search
+31
-2
@@ -161,6 +161,23 @@ class Lean
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getDefinitionsPathsFromComposer() : array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
foreach(Composer::readComposerLock()['packages'] as $package) {
|
||||
foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
|
||||
$list[] = static::pathFromPackage($package, $autoload);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(Composer::readComposerJson()['extra']['lean']['autoload']['definitions'] ?? [] ?? [] as $autoload) {
|
||||
$list[] = getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . $autoload;
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function autoloadDefinitionsFromComposerExtra() : array
|
||||
{
|
||||
$list = [];
|
||||
@@ -187,13 +204,25 @@ class Lean
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected static function pathFromPackage(array $package, array|string $autoload) : string
|
||||
{
|
||||
$vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
|
||||
$filepath = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
|
||||
if (! file_exists($filepath)) {
|
||||
throw new \InvalidArgumentException("Given definition filepath do not exists '$filepath'");
|
||||
}
|
||||
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
protected static function loadFromPackage(array $package, array|string $autoload) : false|array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
if (is_string($autoload)) {
|
||||
$vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
$file = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
$file = static::pathFromPackage($package, $autoload);
|
||||
|
||||
if ( ! file_exists($file) ) {
|
||||
throw new \InvalidArgumentException(sprintf("Given autoload file `%s` from package `%s` was not found or is unreachable", $autoload, $package['name']));
|
||||
|
||||
Reference in new issue
Block a user