Elgg\Http\ResponseFactory::respondWithError PHP Метод

respondWithError() публичный Метод

Send error HTTP response
public respondWithError ( string $error, integer $status_code = ELGG_HTTP_BAD_REQUEST, array $headers = [] ) : Response
$error string Error message
$status_code integer HTTP status code
$headers array HTTP headers (will be discarded on AJAX requests)
Результат Symfony\Component\HttpFoundation\Response
    public function respondWithError($error, $status_code = ELGG_HTTP_BAD_REQUEST, array $headers = [])
    {
        if ($this->ajax->isReady()) {
            return $this->send($this->ajax->respondWithError($error, $status_code));
        }
        if ($this->isXhr()) {
            // xhr calls to non-actions (e.g. ajax/view or ajax/form) need to receive proper HTTP status code
            return $this->send($this->prepareResponse($error, $status_code, $headers));
        }
        $forward_url = $this->request->headers->get('Referer');
        if (!$this->isAction()) {
            $params = ['current_url' => current_page_url(), 'forward_url' => $forward_url];
            // For BC, let plugins serve their own error page
            // @see elgg_error_page_handler
            $forward_reason = (string) $status_code;
            $forward_url = $this->hooks->trigger('forward', $forward_reason, $params, $forward_url);
            if ($this->response_sent) {
                // Response was sent from a forward hook
                return $this->response_sent;
            }
            $params['type'] = $forward_reason;
            $error_page = elgg_view_resource('error', $params);
            return $this->send($this->prepareResponse($error_page, $status_code));
        }
        $forward_url = elgg_normalize_url($forward_url);
        return $this->send($this->prepareRedirectResponse($forward_url));
    }