<?php

use Interop\Container\Pimple\PimpleInterop;
// Load configuration
$config = (require 'config.php');
// Build container
$container = new PimpleInterop();
// Inject config
$container['config'] = $config;
// Inject factories
foreach ($config['dependencies']['factories'] as $name => $object) {
    $container[$name] = $container->share(function ($c) use($object) {
        $factory = new $object();
        return $factory($c);
    });
}
// Inject invokables
foreach ($config['dependencies']['invokables'] as $name => $object) {
    $container[$name] = $container->share(function ($c) use($object) {
        return new $object();
    });
}
return $container;
 /**
  * @expectedException Interop\Container\Pimple\PimpleNotFoundException
  */
 public function testStandardCompliantMode()
 {
     // Let's test a "silex" controller scenario.
     // Silex extends Pimple A.
     // My controller is declared in Pimple B.
     // Silex will query container A but result of container B should be returned.
     // My container references an instance in container A.
     // This should work too.
     $compositeContainer = new CompositeContainer();
     $pimpleA = new PimpleInterop($compositeContainer);
     $pimpleB = new PimpleInterop($compositeContainer);
     $pimpleB['controller'] = $pimpleB->share(function ($pimpleB) {
         return ['result' => $pimpleB['dependency']];
     });
     $pimpleA['dependency'] = $pimpleA->share(function ($pimpleB) {
         return 'myDependency';
     });
     $compositeContainer->addContainer($pimpleA);
     $compositeContainer->addContainer($pimpleB);
     $pimpleA->setMode(PimpleInterop::MODE_STANDARD_COMPLIANT);
     // Let's get the controller from PimpleA (that does not declare it)
     // This should fail
     $controller = $pimpleA->get('controller');
 }