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


PHP Container::resolve方法代码示例

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


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

示例1: executeFilters

 protected function executeFilters()
 {
     $filterObjects = [];
     //Create filter objects
     foreach ($this->filters as $filter) {
         $filterObjects[] = $this->container->resolve($filter);
     }
     //Execute filters
     /** @var FilterAbstract $filterObject */
     foreach ($filterObjects as $filterObject) {
         $filterObject->execute();
     }
 }
开发者ID:marcyniu,项目名称:ai,代码行数:13,代码来源:PipeFilter.php

示例2: callMethods

 /**
  * Execute the methods added via call()
  *
  * @param object $object The instatiated $class on which to call the methods.
  *
  * @return mixed The created object
  */
 protected function callMethods($object)
 {
     if (!empty($this->methods)) {
         foreach (array_reverse($this->methods) as $method => $args) {
             $reflection = new \ReflectionMethod($object, $method);
             $arguments = [];
             foreach ($args as $arg) {
                 if (is_string($arg) && (class_exists($arg) || $this->container->bound($arg))) {
                     $arguments[] = $this->container->resolve($arg);
                     continue;
                 }
                 $arguments[] = $arg;
             }
             $reflection->invokeArgs($object, $arguments);
         }
     }
     return $object;
 }
开发者ID:encorephp,项目名称:container,代码行数:25,代码来源:Definition.php

示例3: resolveArgs

 protected function resolveArgs(\ReflectionMethod $reflected_method, $args)
 {
     $results = [];
     if (is_array($args)) {
         foreach ($reflected_method->getParameters() as $key => $reflected_parameter) {
             try {
                 $class = $reflected_parameter->getClass();
                 $name = $reflected_parameter->getName();
                 if (isset($args[$name])) {
                     $results[$key] = $args[$name];
                     if (is_object($results[$key]) && $results[$key] instanceof DefinitionInterface) {
                         $results[$key] = $results[$key]->resolve();
                     } elseif ($class && is_string($results[$key])) {
                         $results[$key] = $this->container->resolve($results[$key]);
                     } elseif (is_array($results[$key])) {
                         array_walk_recursive($results[$key], function (&$item) {
                             if (is_object($item) && $item instanceof DefinitionInterface) {
                                 $item = $item->resolve();
                             }
                         });
                     }
                 } elseif ($class) {
                     if ($reflected_parameter->allowsNull()) {
                         $results[$key] = null;
                     } else {
                         $results[$key] = $this->container->resolve($class->getName());
                     }
                 } elseif ($reflected_parameter->isOptional()) {
                     $results[$key] = $reflected_parameter->getDefaultValue();
                 }
             } catch (DefinitionException $e) {
                 throw new ResolveArgsException('Can not resolve argument ' . $reflected_parameter->getName() . ' while resolving arguments for ' . $reflected_method->getName(), 0, $e);
             }
         }
     }
     return $results;
 }
开发者ID:erickmerchant,项目名称:wright,代码行数:37,代码来源:Definition.php

示例4: testFakeFile

 /**
  * @covers PublicVendor\Container::resolve
  */
 public function testFakeFile()
 {
     $container = new Container(VENDOR_PATH);
     $result = $container->resolve('fake/vendor', 'fake/file.html');
     $this->assertFalse(file_exists($result));
 }
开发者ID:johnpitcher,项目名称:public-vendor,代码行数:9,代码来源:ContainerTest.php

示例5: runAction

 private static function runAction()
 {
     $action = self::$func;
     if (is_string($action)) {
         $tmp = explode('@', $action);
         $tmp[0] = "\\App\\Controller\\" . $tmp[0];
         $middleware = null;
         if (self::$middleware) {
             $middleClass = "\\App\\Controller\\" . self::$middleware;
             $middleware = Container::resolve($middleClass, 'handle', self::$requestParams);
             if ($middleware == 'next' or is_object($middleware) or is_array($middleware)) {
                 return Container::resolve($tmp[0], $tmp[1], self::$requestParams, $middleware);
             }
             return $middleware;
         }
         return Container::resolve($tmp[0], $tmp[1], self::$requestParams);
     }
     return call_user_func_array($action, self::$requestParams);
 }
开发者ID:VasiliyLiao,项目名称:SimpleFrameWork,代码行数:19,代码来源:Route.php


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