Ejemplo n.º 1
0
 /**
  * @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));
     });
 }
Ejemplo n.º 2
0
 /**
  * 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);
     }
 }
 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);
 }
 /**
  * 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);
     }
 }
 /**
  * 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));
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * @param ServerRequestInterface $request
  *
  * @return Application
  */
 public function setRequest(ServerRequestInterface $request) : Application
 {
     $this->request = $request;
     $this->container->add(ServerRequestInterface::class, $request);
     return $this;
 }