push() public method

Push an emitter to the stack.
public push ( Zend\Diactoros\Response\EmitterInterface $emitter )
$emitter Zend\Diactoros\Response\EmitterInterface
 /**
  * Create and return an Application instance.
  *
  * Will inject the instance with the container and/or router when provided;
  * otherwise, it will use a ZF2 ServiceManager instance and the FastRoute
  * router bridge.
  *
  * The factory also injects the Application with an Emitter\EmitterStack that
  * composes a SapiEmitter at the bottom of the stack (i.e., will execute last
  * when the stack is iterated).
  *
  * @param null|ContainerInterface $container IoC container from which to
  *     fetch middleware defined as services; defaults to a ServiceManager
  *     instance
  * @param null|Router\RouterInterface $router Router implementation to use;
  *     defaults to the FastRoute router bridge.
  * @return Application
  */
 public static function create(ContainerInterface $container = null, Router\RouterInterface $router = null)
 {
     $container = $container ?: new ServiceManager();
     $router = $router ?: new Router\FastRouteRouter();
     $emitter = new Emitter\EmitterStack();
     $emitter->push(new SapiEmitter());
     return new Application($router, $container, null, $emitter);
 }
示例#2
0
 public function build($env = null) : Application
 {
     $this->env = $env;
     $router = new FastRouteRouter();
     $finalHandler = new FinalHandler();
     $emitter = new EmitterStack();
     if ($this->useSAPIEmitter) {
         $emitter->push(new SapiEmitter());
     } else {
         $emitter->push(new PHPUnitEmitter());
     }
     foreach ($this->initScripts as $initScriptClassName) {
         $script = new $initScriptClassName();
         $script($this);
     }
     $app = new Application($router, $this->container, $finalHandler, $emitter);
     foreach ($this->initAppScripts as $initAppScriptClassName) {
         $script = new $initAppScriptClassName();
         $script($app);
     }
     $this->container->set(Application::class, $app);
     return $app;
 }
 /**
  * Create the default emitter stack.
  *
  * @return EmitterStack
  */
 private function createEmitterStack()
 {
     $emitter = new EmitterStack();
     $emitter->push(new SapiEmitter());
     return $emitter;
 }
示例#4
0
<?php

/** @var \Zend\Expressive\Application $application */
use Zend\Diactoros\Response\SapiEmitter;
use Zend\Expressive\Emitter\EmitterStack;
use Zend\Expressive\Router\FastRouteRouter;
use Zend\ServiceManager\ServiceManager;
$application = (require __DIR__ . '/../../backend/bootstrap/bootstrap.php');
$container = new ServiceManager();
$router = new FastRouteRouter();
$emitter = new EmitterStack();
$emitter->push(new SapiEmitter());
$RESTApiApplication = new \Zend\Expressive\Application($router, $container, new \CASS\Application\Bootstrap\FinalHandler(), $emitter);
$RESTApiApplication->pipe('/backend/api', $application);
$RESTApiApplication->pipeRoutingMiddleware();
$RESTApiApplication->pipeDispatchMiddleware();
$RESTApiApplication->run();