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


PHP ContainerInterface::set方法代碼示例

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


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

示例1: __construct

 /**
  * Constructor application.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request
  * @param \Psr\Http\Message\ResponseInterface $response
  * @param \Interop\Container\ContainerInterface $container
  */
 public function __construct(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->container = $container;
     $this->request = $request;
     $this->response = $response;
     // Check container set exist
     if (method_exists($this->container, 'set')) {
         // Inject self application for middlewares freedom
         $this->container->set(ApplicationInterface::class, $this);
     }
 }
開發者ID:aracaw,項目名稱:wiring,代碼行數:18,代碼來源:InvolkerMiddleware.php

示例2: __construct

 /**
  * Application initialization.
  *
  * @param mixed              $router    Routing system.
  * @param ContainerInterface $container Dependency Injection container.
  */
 public function __construct($router = null, ContainerInterface $container = null)
 {
     $this->container = $container ?: $this->buildContainer(Loader::load());
     $container =& $this->container;
     $this->response = new Response();
     $this->request = ServerRequestFactory::fromGlobals();
     if ($router == null && $container->has('router') == false) {
         throw new Exception('Define router config');
     }
     if ($container->has('router') == false) {
         $container->set('router', $router);
     }
     $container->set('event_manager', DI\object('Zend\\EventManager\\EventManager'));
     $container->set('dispatcher', DI\object('GianArb\\Penny\\Dispatcher')->constructor($container->get('router')));
     $container->set('di', $container);
 }
開發者ID:butkimtinh,項目名稱:penny,代碼行數:22,代碼來源:App.php

示例3: set

 /**
  * Define an object or a value in the container.
  *
  * @param string $name Entry name
  * @param mixed $value Value, use definition helpers to define objects
  * @throws \Exception
  */
 public function set($name, $value)
 {
     if (!method_exists($this->container, 'set')) {
         throw new Exception('Container method not found');
     }
     return $this->container->set($name, $value);
 }
開發者ID:aracaw,項目名稱:wiring,代碼行數:14,代碼來源:AbstractController.php


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