1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_modules\Loaders\Kw; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_autoload\AutoloadException; |
|
|
|
|
7
|
|
|
use kalanis\kw_modules\Interfaces\ILoader; |
8
|
|
|
use kalanis\kw_modules\Interfaces\IMdTranslations; |
9
|
|
|
use kalanis\kw_modules\Interfaces\IModule; |
10
|
|
|
use kalanis\kw_modules\ModuleException; |
11
|
|
|
use kalanis\kw_modules\Traits\TMdLang; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class AKwLoader |
16
|
|
|
* @package kalanis\kw_modules\Loaders\Kw |
17
|
|
|
* Load modules data from defined targets |
18
|
|
|
* @codeCoverageIgnore contains external autoloader |
19
|
|
|
* |
20
|
|
|
* Name is passed as first big and the rest little ( ucfirst(strtolower($x)) ) |
21
|
|
|
* - lookup by curly braces |
22
|
|
|
* |
23
|
|
|
* KWCMS is for kw_autoloader on "vendor" position and modules dir on "project" position |
24
|
|
|
*/ |
25
|
|
|
abstract class ALoader implements ILoader |
26
|
|
|
{ |
27
|
|
|
use TMdLang; |
28
|
|
|
|
29
|
1 |
|
public function __construct(?IMdTranslations $lang = null) |
30
|
|
|
{ |
31
|
1 |
|
if (class_exists('\kalanis\kw_autoload\Autoload')) { |
32
|
|
|
\kalanis\kw_autoload\Autoload::addPath('%2$s%1$smodules%1$s%5$s%1$sphp-src%1$s%6$s'); |
|
|
|
|
33
|
|
|
\kalanis\kw_autoload\Autoload::addPath('%2$s%1$smodules%1$s%5$s%1$ssrc%1$s%6$s'); |
34
|
|
|
\kalanis\kw_autoload\Autoload::addPath('%2$s%1$smodules%1$s%5$s%1$s%6$s'); |
35
|
|
|
} |
36
|
1 |
|
$this->setMdLang($lang); |
37
|
1 |
|
} |
38
|
|
|
|
39
|
|
|
public function load(array $module, array $constructParams = []): ?IModule |
40
|
|
|
{ |
41
|
|
|
/** @var class-string<IModule> $classPath */ |
42
|
|
|
$classPath = $this->getClassName($module); |
43
|
|
|
try { |
44
|
|
|
$reflection = new \ReflectionClass($classPath); |
45
|
|
|
$module = $reflection->newInstanceArgs($constructParams); |
46
|
|
|
if (!$module instanceof IModule) { |
47
|
|
|
throw new ModuleException($this->getMdLang()->mdNotInstanceOfIModule($classPath)); |
48
|
|
|
} |
49
|
|
|
return $module; |
50
|
|
|
} catch (AutoloadException | \ReflectionException $ex) { |
51
|
|
|
return null; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string[] $module |
57
|
|
|
* @throws ModuleException |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
abstract protected function getClassName(array $module): string; |
61
|
|
|
} |
62
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths