/** * Initialize call stacks * Handle application execution * Set response body */ protected function handle() { $this->callStack = $this->finding->getMiddlewares(); // resolve registry $this->middlewareRegistry->resolve($this, $this->callStack); $resolver = $this->app->create('handler.resolver'); // add final handle $this->callStack[] = $resolver->resolve($this, $this->route->getProperty('execute'), $this->finding->getHandlers()); // first handle. $handle = reset($this->callStack); // execute. $this->response->setBody($handle($this)); }