/** * @description set response code */ public function callResponse() { if (isset($this->route->getDetail()['response_templates']) && isset($this->route->getDetail()['response_templates'][$code = $this->response->getStatusCode()])) { $this->route->setCallback($this->route->getDetail()['response_templates'][$code]); $matcher = null; foreach ($this->matcher as $instance) { if ($instance instanceof ArrayMatcher) { $matcher = $instance; } } if (is_null($matcher)) { $matcher = new ArrayMatcher($this); } foreach (call_user_func([$matcher, 'getResolver']) as $match) { if (is_array($target = call_user_func_array([$matcher, $match], [$this->route->getCallback()]))) { call_user_func_array([$matcher, 'setTarget'], [$target]); $this->callTarget(); break; } } $this->response->setStatusCode($code); } $this->response->send(); }