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