class AjaxResponse extends JsonResponse implements AttachmentsInterface (View source)

JSON response object for AJAX requests.

Traits

Provides an implementation of AttachmentsInterface.

Properties

protected array $attachments

The attachments for this response.

from  AttachmentsTrait
protected array $commands

The array of ajax commands.

Methods

getAttachments()

{@inheritdoc}

addAttachments(array $attachments)

{@inheritdoc}

setAttachments(array $attachments)

{@inheritdoc}

$this
addCommand(CommandInterface $command, bool $prepend = FALSE)

Add an AJAX command to the response.

array
getCommands()

Gets all AJAX commands.

Details

getAttachments()

{@inheritdoc}

addAttachments(array $attachments)

{@inheritdoc}

Parameters

array $attachments

setAttachments(array $attachments)

{@inheritdoc}

Parameters

array $attachments

$this addCommand(CommandInterface $command, bool $prepend = FALSE)

Add an AJAX command to the response.

Parameters

CommandInterface $command

An AJAX command object implementing CommandInterface.

bool $prepend

A boolean which determines whether the new command should be executed before previously added commands. Defaults to FALSE.

Return Value

$this

The current AjaxResponse.

array getCommands()

Gets all AJAX commands.

Return Value

array

Returns render arrays for all previously added commands.