/**
  * Init the container and add the config class
  */
 public function setupContainer()
 {
     $this->container = new Container();
     $this->container->delegate(new ReflectionContainer());
     $this->container->add("config", 'Playground\\Framework\\Config\\Config', true)->withArgument($this->configFile);
     $this->container->add("request", $this->request, true);
 }
Exemple #2
0
 public function __construct()
 {
     $this->container = new Container();
     $this->container->delegate(new ReflectionContainer());
     $this->container->add('baseDir', dirname(__DIR__));
     $this->loadConfig();
     $this->loadServiceProviders();
 }
 public function setUp()
 {
     $configFile = __DIR__ . "/../mock/config/testSettings.php";
     $this->container = new Container();
     $this->container->delegate(new ReflectionContainer());
     $this->container->add("config", 'Playground\\Framework\\Config\\Config', true)->withArgument($configFile);
     $this->container->addServiceProvider('Playground\\Framework\\Toybox\\Twig\\TwigServiceProvider');
     $this->view = new View($this->container);
 }
 /**
  * @return Container
  */
 protected function makeContainer()
 {
     $container = new Container();
     $container->delegate(new ReflectionContainer());
     $container->addServiceProvider(new RequestServiceProvider());
     $container->addServiceProvider(new RoutingServiceProvider());
     $container->addServiceProvider(new PlatesServiceProvider());
     $container->share(Configuration::class, function () {
         return $this->configuration;
     });
     return $container;
 }
Exemple #5
0
 function getContainer()
 {
     static $container;
     if (!isset($container)) {
         $container = new Container();
         //. Attempt to autowire class constructor dependencies
         $container->delegate(new ReflectionContainer());
         // register default config file
         $container->add('configFile', SOVEREIGN_CONFIG_FILE);
         // Add the default system service provider
         $container->addServiceProvider(\Sovereign\Service\SystemServiceProvider::class);
     }
     return $container;
 }
<?php

/**
 * @file
 * The app container, handles dependency injection.
 */
use League\Container\Container;
use League\Container\ReflectionContainer;
// Get the app container.
$container = new Container();
// Utilise container 'auto wiring' to automatically inject
// dependencies into our controllers.
$container->delegate(new ReflectionContainer());
/**
 * ----------------------------------------------------------------------------
 * Core Services
 * ----------------------------------------------------------------------------
 * These services are required by core. DO NOT remove these entries unless
 * you are very sure what you're doing.
 *
 * Really.
 */
$container->share('Symfony\\Component\\HttpFoundation\\Request', function () {
    return Symfony\Component\HttpFoundation\Request::createFromGlobals();
});
$container->share('Symfony\\Component\\HttpFoundation\\Response');
/**
 * ----------------------------------------------------------------------------
 * Additional Services
 * ----------------------------------------------------------------------------
 * Define extra services for the application to use here. The services can be