Exemple #1
0
 /**
  * Starts the Loader and loads the right object in base of the routing
  *
  * @return void
  */
 private function initializeConfig()
 {
     $this->container->set('config.fileLocation', 'app/config/config.yaml');
     $this->container->set('config.parsed', $this->container->get('yaml')->loadConfigFile($this->container->get('config.fileLocation')));
     $this->container->set('config', $this->container->share(function ($c) {
         return new Config($c->get('config.parsed'));
     }));
 }
Exemple #2
0
 public function testDiContainerShareShouldReturnAlwaysTheSameObjectEvenIfItIsAClosure()
 {
     $dic = new DIContainer();
     $dic['shared_service'] = $dic->share(function () {
         return new Service();
     });
     $serviceOne = $dic['shared_service'];
     $this->assertInstanceOf('Aliegon\\Tests\\DependencyInjection\\Service', $serviceOne);
     $serviceTwo = $dic['shared_service'];
     $this->assertInstanceOf('Aliegon\\Tests\\DependencyInjection\\Service', $serviceTwo);
     $this->assertSame($serviceOne, $serviceTwo);
 }