当前位置: 首页>>代码示例>>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;未经允许,请勿转载。