kernal clean-up
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace KTXC\Module;
|
||||
|
||||
use KTXC\Server;
|
||||
use KTXC\Application;
|
||||
|
||||
/**
|
||||
* Custom autoloader for modules that allows PascalCase namespaces
|
||||
@@ -73,7 +73,7 @@ class ModuleAutoloader
|
||||
}
|
||||
|
||||
// Register module namespaces with Composer ClassLoader
|
||||
$composerLoader = Server::getComposerLoader();
|
||||
$composerLoader = \KTXC\Application::getComposerLoader();
|
||||
if ($composerLoader !== null) {
|
||||
foreach ($this->namespaceMap as $namespace => $folderName) {
|
||||
$composerLoader->addPsr4(
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
namespace KTXC\Module;
|
||||
|
||||
use Exception;
|
||||
use DI\Attribute\Inject;
|
||||
use KTXC\Module\Store\ModuleStore;
|
||||
use KTXC\Module\Store\ModuleEntry;
|
||||
use KTXC\Server;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use KTXF\Module\ModuleInstanceInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use ReflectionClass;
|
||||
@@ -17,10 +18,12 @@ class ModuleManager
|
||||
|
||||
public function __construct(
|
||||
private readonly ModuleStore $repository,
|
||||
private readonly LoggerInterface $logger
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly ContainerInterface $container,
|
||||
#[Inject('rootDir')] private readonly string $rootDir
|
||||
) {
|
||||
// Initialize server root path
|
||||
$this->serverRoot = Server::runtimeRootLocation();
|
||||
$this->serverRoot = $rootDir;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,7 +396,6 @@ class ModuleManager
|
||||
}
|
||||
|
||||
// For modules with dependencies, try to resolve them from the container
|
||||
$container = Server::runtimeContainer();
|
||||
$parameters = $constructor->getParameters();
|
||||
$args = [];
|
||||
|
||||
@@ -403,8 +405,8 @@ class ModuleManager
|
||||
$typeName = $type->getName();
|
||||
|
||||
// Try to get service from container
|
||||
if ($container->has($typeName)) {
|
||||
$args[] = $container->get($typeName);
|
||||
if ($this->container->has($typeName)) {
|
||||
$args[] = $this->container->get($typeName);
|
||||
} elseif ($parameter->isDefaultValueAvailable()) {
|
||||
$args[] = $parameter->getDefaultValue();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user