當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。