| 1 |
<?php |
| 2 |
|
| 3 |
namespace Monei\Core; |
| 4 |
|
| 5 |
use DI\Container; |
| 6 |
use DI\ContainerBuilder; |
| 7 |
|
| 8 |
class ContainerProvider { |
| 9 |
private static ?Container $container = null; |
| 10 |
|
| 11 |
public static function getContainer(): Container { |
| 12 |
if ( self::$container === null ) { |
| 13 |
self::buildContainer(); |
| 14 |
} |
| 15 |
return self::$container; |
| 16 |
} |
| 17 |
|
| 18 |
private static function buildContainer(): void { |
| 19 |
$containerBuilder = new ContainerBuilder(); |
| 20 |
$containerBuilder->addDefinitions( __DIR__ . '/container-definitions.php' ); |
| 21 |
self::$container = $containerBuilder->build(); |
| 22 |
} |
| 23 |
} |
| 24 |
|