当前位置: 首页>>代码示例>>PHP>>正文


PHP Loader\ClosureLoader类代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\Loader\ClosureLoader的典型用法代码示例。如果您正苦于以下问题:PHP ClosureLoader类的具体用法?PHP ClosureLoader怎么用?PHP ClosureLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ClosureLoader类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLoad

 public function testLoad()
 {
     $loader = new ClosureLoader($container = new ContainerBuilder());
     $loader->load(function ($container) {
         $container->setParameter('foo', 'foo');
     });
     $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \\Closure resource');
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:8,代码来源:ClosureLoaderTest.php

示例2: testLazyLoadedService

 public function testLazyLoadedService()
 {
     $loader = new ClosureLoader($container = new ContainerBuilder());
     $loader->load(function (ContainerBuilder $container) {
         $container->set('a', new \BazClass());
         $definition = new Definition('BazClass');
         $definition->setLazy(true);
         $container->setDefinition('a', $definition);
     });
     $container->setResourceTracking(true);
     $container->compile();
     $class = new \BazClass();
     $reflectionClass = new \ReflectionClass($class);
     $r = new \ReflectionProperty($container, 'resources');
     $r->setAccessible(true);
     $resources = $r->getValue($container);
     $classInList = false;
     foreach ($resources as $resource) {
         if ($resource->getResource() === $reflectionClass->getFileName()) {
             $classInList = true;
             break;
         }
     }
     $this->assertTrue($classInList);
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:25,代码来源:ContainerBuilderTest.php

示例3: createContainerFromClosure

 protected function createContainerFromClosure($closure, $data = array())
 {
     $container = $this->createContainer($data);
     $container->registerExtension(new FrameworkExtension());
     $loader = new ClosureLoader($container);
     $loader->load($closure);
     $container->getCompilerPassConfig()->setOptimizationPasses(array());
     $container->getCompilerPassConfig()->setRemovingPasses(array());
     $container->compile();
     return $container;
 }
开发者ID:Gladhon,项目名称:symfony,代码行数:11,代码来源:FrameworkExtensionTest.php


注:本文中的Symfony\Component\DependencyInjection\Loader\ClosureLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。