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


PHP Di::injectDependencies方法代码示例

本文整理汇总了PHP中Zend\Di\Di::injectDependencies方法的典型用法代码示例。如果您正苦于以下问题:PHP Di::injectDependencies方法的具体用法?PHP Di::injectDependencies怎么用?PHP Di::injectDependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Di\Di的用法示例。


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

示例1: initialize

 /**
  * @param $instance
  */
 public function initialize($instance, ServiceLocatorInterface $serviceLocator)
 {
     $instanceManager = $this->di->instanceManager;
     $this->di->instanceManager = $this->diInstanceManagerProxy;
     try {
         $this->di->injectDependencies($instance);
         $this->di->instanceManager = $instanceManager;
     } catch (\Exception $e) {
         $this->di->instanceManager = $instanceManager;
         throw $e;
     }
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:15,代码来源:DiServiceInitializer.php

示例2: __invoke

 /**
  * Initialize an instance via zend-di.
  *
  * @param mixed|ContainerInterface $first Container when under
  *     zend-servicemanager v3, instance to initialize otherwise.
  * @param ContainerInterface|mixed $second Instance to initialize when
  *     under zend-servicemanager v3, container otherwise.
  * @return void
  */
 public function __invoke($first, $second)
 {
     if ($first instanceof AbstractPluginManager || $second instanceof ContainerInterface) {
         $instance = $first;
     } else {
         $instance = $second;
     }
     $instanceManager = $this->di->instanceManager;
     $this->di->instanceManager = $this->diInstanceManagerProxy;
     try {
         $this->di->injectDependencies($instance);
     } catch (Exception $e) {
         throw $e;
     } finally {
         $this->di->instanceManager = $instanceManager;
     }
 }
开发者ID:zendframework,项目名称:zend-servicemanager-di,代码行数:26,代码来源:DiServiceInitializer.php

示例3: testDiWillInjectDependenciesForInstance

 public function testDiWillInjectDependenciesForInstance()
 {
     $di = new Di();
     // for setter injection, the dependency is not required, thus it must be forced
     $classDef = new Definition\ClassDefinition('ZendTest\\Di\\TestAsset\\SetterInjection\\B');
     $classDef->addMethod('setA', true);
     $di->definitions()->addDefinition($classDef, false);
     // top of stack b/c Runtime is already there
     $b = new TestAsset\SetterInjection\B();
     $di->injectDependencies($b);
     $this->assertInstanceOf('ZendTest\\Di\\TestAsset\\SetterInjection\\A', $b->a);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:12,代码来源:DiTest.php


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