System\Traits\ResponseMaker

Source: ~/modules/system/traits/ResponseMaker.php

Response Maker Trait Stores attributes the can be used to prepare a response from the server.

Protected properties

protected int $statusCode

Response status code

protected mixed $responseOverride

Override the standard controller response.

protected Symfony\Component\HttpFoundation\ResponseHeaderBag $responseHeaderBag

Public methods

public Symfony\Component\HttpFoundation\ResponseHeaderBag|null getResponseHeaders()

Get the header response bag

public int getStatusCode()

Returns the status code for the current web response.

public mixed makeResponse(mixed $contents)

Prepares a response that considers overrides and custom responses.

Parameters
  • mixed $contents

public $this setResponse(mixed $response)

Sets the response for the current page request cycle, this value takes priority over the standard response prepared by the controller.

Parameters
  • mixed $response - Response object or string

public $this setResponseCookie(Symfony\Component\HttpFoundation\Cookie|mixed $cookie)

Add a cookie to the response.

Parameters
  • Symfony\Component\HttpFoundation\Cookie|mixed $cookie

public $this setResponseHeader(string $key, array|string $values, bool $replace=true)

Set a header on the Response.

Parameters
  • string $key
  • array|string $values
  • bool $replace

public $this setStatusCode(int $code)

Sets the status code for the current web response.

Parameters
  • int $code - Status code