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