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


PHP ContainerInterface::make方法代码示例

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


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

示例1: make

 /**
  * Resolves an entry by its name.
  * If given a class name, it will return a new instance of that class.
  *
  * @param string $name Entry name or a class name.
  * @param array $parameters Optional parameters to use to build the entry. Use this to force specific
  *                           parameters to specific values. Parameters not defined in this array will
  *                           be automatically resolved.
  *
  * @throws \Exception       Error while resolving the entry.
  * @return mixed
  */
 public function make($name, array $parameters = [])
 {
     if (!method_exists($this->container, 'make')) {
         throw new Exception('Container method not found');
     }
     return $this->container->make($name, $parameters);
 }
开发者ID:aracaw,项目名称:wiring,代码行数:19,代码来源:AbstractController.php

示例2: 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

示例3: __invoke

 /**
  * Create an object
  *
  * @param  ContainerInterface $container
  * @param  string $requestedName
  * @param  null|array $options
  *
  * @return object
  * @throws ServiceNotFoundException if unable to resolve the service.
  * @throws ServiceNotCreatedException if an exception is raised when
  *     creating a service.
  * @throws ContainerException if any other error occurs
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     if ($container instanceof Container) {
         return $container->make($requestedName, $options ? $options : []);
     } else {
         return $container->get($requestedName);
     }
 }
开发者ID:milsdev,项目名称:wordpress-plugin-sarcofag,代码行数:21,代码来源:AbstractFactory.php


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