DI\ContainerBuilder::wrapContainer PHP Method

wrapContainer() public method

If PHP-DI's container is wrapped by another container, we can set this so that PHP-DI will use the wrapper rather than itself for building objects.
public wrapContainer ( Interop\Container\ContainerInterface $otherContainer )
$otherContainer Interop\Container\ContainerInterface
    public function wrapContainer(ContainerInterface $otherContainer)
    {
        $this->ensureNotLocked();
        $this->wrapperContainer = $otherContainer;
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: AppTest.php プロジェクト: wdalmut/frankie
 public function setUp()
 {
     $loader = (include __DIR__ . '/../vendor/autoload.php');
     AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
     $container = new CompositeContainer();
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->wrapContainer($container);
     $diContainer = $builder->build();
     $container->addContainer($diContainer);
     $reader = new AnnotationReader();
     $routeLoader = new RouteAnnotationClassLoader($reader);
     $loader = new AnnotationDirectoryLoader(new FileLocator([__DIR__ . '/app']), $routeLoader);
     $routes = $loader->load(__DIR__ . '/app');
     $context = new RequestContext();
     $matcher = new UrlMatcher($routes, $context);
     $hookReader = new HookReader($reader);
     $executor = new AnnotExecutor($container, $hookReader);
     $this->app = new App($matcher, $executor);
 }
All Usage Examples Of DI\ContainerBuilder::wrapContainer