The implementations emit() method iterates itself. When iterating the stack, the first emitter to return a value that is not identical to boolean false will short-circuit iteration.
Inheritance: extends SplStac\SplStack, implements Zend\Diactoros\Response\EmitterInterface
コード例 #1
0
 /**
  * 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
ファイル: AppBuilder.php プロジェクト: cass-project/cass
 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;
 }
コード例 #3
0
 /**
  * Create the default emitter stack.
  *
  * @return EmitterStack
  */
 private function createEmitterStack()
 {
     $emitter = new EmitterStack();
     $emitter->push(new SapiEmitter());
     return $emitter;
 }
コード例 #4
0
ファイル: backend.php プロジェクト: cass-project/cass
<?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();