Example #1
0
 /**
  * Put some middleware on the front of the middleware chain
  * 
  * @param \League\Tactician\Middleware $middleware
  */
 public function prependMiddlewareChain(Middleware $middleware)
 {
     $oldMiddlewareChain = $this->middlewareChain;
     $this->middlewareChain = function ($command) use($middleware, $oldMiddlewareChain) {
         return $middleware->execute($command, $oldMiddlewareChain);
     };
 }
 protected function execute(Middleware $middleware, $command, $expectedNextCommand, $executeResult = null)
 {
     $nextWasCalled = false;
     $middleware->execute($command, function ($nextCommand) use($expectedNextCommand, &$nextWasCalled, $executeResult) {
         \PHPUnit_Framework_Assert::assertSame($expectedNextCommand, $nextCommand);
         $nextWasCalled = true;
         return $executeResult;
     });
     if (!$nextWasCalled) {
         throw new \LogicException('Middleware should have called the next callable.');
     }
 }
 /**
  * @param mixed $command
  */
 public function handle($command)
 {
     $this->commandMiddleware->execute($command, function () {
     });
 }