Add custom Container extending League\Container
Some checks are pending
CI / build_and_test (push) Waiting to run
Some checks are pending
CI / build_and_test (push) Waiting to run
This commit is contained in:
parent
42df7cac0f
commit
9e1aedfbad
|
|
@ -17,7 +17,7 @@ $dotenv->safeLoad();
|
|||
|
||||
$mergedEnv = $_ENV + $_SERVER;
|
||||
|
||||
use League\Container\Container;
|
||||
use SiteWeaver\Core\Container;
|
||||
use SiteWeaver\Core\Config;
|
||||
use SiteWeaver\Core\Router;
|
||||
$container = new Container();
|
||||
|
|
|
|||
38
src/Site/Core/Container.php
Normal file
38
src/Site/Core/Container.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* File: src/Site/Core/Container.php
|
||||
*
|
||||
* Author: Funky Waddle
|
||||
* Date: 2026-09-10
|
||||
*
|
||||
* Purpose:
|
||||
* A thin wrapper around League\Container\Container to enable future custom
|
||||
* functionality while preserving the existing API.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SiteWeaver\Core;
|
||||
|
||||
use League\Container\Container as LeagueContainer;
|
||||
|
||||
/**
|
||||
* Custom DI container that extends League's container.
|
||||
* It can be extended with additional methods without affecting
|
||||
* existing code that relies on the League implementation.
|
||||
*/
|
||||
class Container extends LeagueContainer
|
||||
{
|
||||
/**
|
||||
* Construct a new custom container.
|
||||
*
|
||||
* @param array<string, mixed> $services Optional initial service definitions
|
||||
*/
|
||||
public function __construct(array $services = [])
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
foreach ($services as $key=>$svc) {
|
||||
$this->add($key, $svc);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue