當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContainerInterface::call方法代碼示例

本文整理匯總了PHP中Interop\Container\ContainerInterface::call方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::call方法的具體用法?PHP ContainerInterface::call怎麽用?PHP ContainerInterface::call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Interop\Container\ContainerInterface的用法示例。


在下文中一共展示了ContainerInterface::call方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: call

 /**
  * Call the given function using the given parameters.
  *
  * Missing parameters will be resolved from the container.
  *
  * @param callable $callable Function to call.
  * @param array $parameters Parameters to use. Can be indexed by the parameter names
  *                             or not indexed (same order as the parameters).
  *                             The array can also contain DI definitions, e.g. DI\get().
  *
  * @throws \Exception
  * @return mixed Result of the function.
  */
 public function call($callable, array $parameters = [])
 {
     if (!method_exists($this->container, 'call')) {
         throw new Exception('Container method not found');
     }
     return $this->container->call($callable, $parameters);
 }
開發者ID:aracaw,項目名稱:wiring,代碼行數:20,代碼來源:AbstractController.php

示例2: registerHook

 /**
  * Registers/Runs a Hook File.
  *
  * @param  string $file The filepath to where the hook exists.
  * @return void
  */
 private function registerHook($file)
 {
     $hook = import($file);
     if (is_callable($hook)) {
         $this->container->call($hook, ['config' => $this->config]);
     }
 }
開發者ID:fructify,項目名稱:theme,代碼行數:13,代碼來源:Kernel.php

示例3: discoverRoutes

 /**
  * Finds all theme route files and adds the routes to the RouteCollection.
  *
  * @return void
  */
 private function discoverRoutes()
 {
     // Where are our routes located?
     $parentRoutes = $this->config->paths->theme->parent->routes;
     $childRoutes = $this->config->paths->theme->child->routes;
     $files = $this->finder->createFinder()->files()->name('*.php')->in($parentRoutes);
     if ($parentRoutes != $childRoutes && is_dir($childRoutes)) {
         $files = $files->in($childRoutes);
     }
     // Collect all the files
     $splFiles = [];
     foreach ($files as $file) {
         $splFiles[] = $file;
     }
     // Now we need to sort them ourselves because it seems Finder's
     // sortByName(), only sorts per in('dir') and not across the
     // entire list.
     $orderedFiles = Linq::from($splFiles)->orderBy('$v', function ($a, $b) {
         return strnatcasecmp($a->getBasename('.php'), $b->getBasename('.php'));
     });
     // Finally lets add some routes.
     foreach ($orderedFiles as $file) {
         $route = import($file->getRealPath(), ['route' => $this->routes]);
         if (is_callable($route)) {
             $this->container->call($route, ['config' => $this->config]);
         }
     }
 }
開發者ID:fructify,項目名稱:theme,代碼行數:33,代碼來源:Router.php

示例4: dispatch

 /**
  * Dispatch a route.
  *
  * @param ResolvedRequestInterface $resolvedRequest A resolved request.
  * @return string The response.
  */
 public function dispatch(ResolvedRequestInterface $resolvedRequest)
 {
     $route = $resolvedRequest->getRoute();
     $controller = $this->container->make($route->getController(), ['resolvedRequest' => $resolvedRequest]);
     // Call the before hook, if defined.
     if (method_exists($controller, 'before')) {
         $this->container->call([$controller, 'before'], ['resolvedRequest' => $resolvedRequest]);
     }
     // Call the action.
     $response = $this->container->call([$controller, 'action' . $route->getAction()], ['resolvedRequest' => $resolvedRequest]);
     // Call the after hook, if defined.
     if (method_exists($controller, 'after')) {
         $this->container->call([$controller, 'after'], ['resolvedRequest' => $resolvedRequest]);
     }
     return $response;
 }
開發者ID:air-php,項目名稱:dispatcher,代碼行數:22,代碼來源:Dispatcher.php

示例5: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Route $route, array $inputs)
 {
     return $this->invoker->call($route->getHandler(), [$inputs]);
 }
開發者ID:domynation,項目名稱:domynation-framework,代碼行數:7,代碼來源:HandlingMiddleware.php

示例6: resolve

 /**
  * Used by Relay\Runner when it dispatches the middleware stack.
  *
  * @param  string $file
  * @return Closure
  */
 private function resolve($file)
 {
     return function (IServerRequest $request, IResponse $response, callable $next) use($file) {
         return $this->container->call(import($file), ['request' => $request, 'response' => $response, 'next' => $next, 'config' => $this->config]);
     };
 }
開發者ID:fructify,項目名稱:theme,代碼行數:12,代碼來源:Middleware.php


注:本文中的Interop\Container\ContainerInterface::call方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。