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


PHP ContainerInterface::add方法代码示例

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


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

示例1: register

 /**
  * @return void
  */
 public function register()
 {
     $this->container->add(ResponseInterface::class, \Zend\Diactoros\Response::class);
     $this->container->add(Router::class, function () {
         return new Router($this->container->get(RouteInterface::class));
     });
 }
开发者ID:ytake,项目名称:vu,代码行数:10,代码来源:Dependency.php

示例2: set

 /**
  * Sets the component.
  *
  * @param  \Interop\Container\ContainerInterface $container
  * @return void
  */
 public function set(ContainerInterface &$container)
 {
     if ($container instanceof Container) {
         $container->add('Psr\\Http\\Message\\ServerRequestInterface', $this->request);
         $container->add('Psr\\Http\\Message\\ResponseInterface', $this->response);
     }
 }
开发者ID:rougin,项目名称:slytherin-skeleton,代码行数:13,代码来源:HttpComponent.php

示例3: __invoke

 public function __invoke(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, callable $next)
 {
     //Save session to request
     $attr = $this->attribute;
     $this->container->add('sessions.' . $this->attribute, function () use($request, $attr) {
         return $request->getAttribute($attr);
     });
     return $next($request, $response);
 }
开发者ID:laasti,项目名称:sessions,代码行数:9,代码来源:SaveSessionToContainerMiddleware.php

示例4: set

 /**
  * Sets the component and add it to the container of your choice.
  *
  * @param  \Interop\Container\ContainerInterface $container
  * @return void
  */
 public function set(ContainerInterface &$container)
 {
     $config = Setup::createAnnotationMetadataConfiguration(config('doctrine.model_paths'), config('doctrine.developer_mode'));
     $config->setProxyDir(config('doctrine.proxy_path'));
     $config->setAutoGenerateProxyClasses(config('doctrine.developer_mode'));
     $entityManager = EntityManager::create(config('database.mysql'), $config);
     if ($container instanceof Container) {
         $container->add('Doctrine\\ORM\\EntityManager', $entityManager);
     }
 }
开发者ID:rougin,项目名称:slytherin-skeleton,代码行数:16,代码来源:DoctrineComponent.php

示例5: set

 /**
  * Sets the component.
  *
  * @param  \Interop\Container\ContainerInterface $container
  * @return void
  */
 public function set(ContainerInterface &$container)
 {
     $entityManager = $container->get('Doctrine\\ORM\\EntityManager');
     $path = base('src/Repositories/');
     $files = glob($path . '*Repository.php');
     foreach ($files as $item) {
         $entity = str_replace([$path, 'Repository.php'], ['', ''], $item);
         $model = 'App\\Models\\' . $entity;
         $name = 'App\\Repositories\\' . $entity . 'Repository';
         $metadata = $entityManager->getClassMetadata($model);
         if ($container instanceof Container) {
             $container->add($name, new $name($entityManager, $metadata));
         }
     }
 }
开发者ID:rougin,项目名称:slytherin-skeleton,代码行数:21,代码来源:RepositoryComponent.php

示例6: setRequest

 /**
  * @param ServerRequestInterface $request
  *
  * @return Application
  */
 public function setRequest(ServerRequestInterface $request) : Application
 {
     $this->request = $request;
     $this->container->add(ServerRequestInterface::class, $request);
     return $this;
 }
开发者ID:ytake,项目名称:vu,代码行数:11,代码来源:Application.php


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