class ViewAjaxResponse extends AjaxResponse (View source)

Custom JSON response object for an ajax view response.

We use a special response object to be able to fire a proper alter hook.

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.

from  AjaxResponse
protected ViewExecutable $view

The view executed on this ajax request.

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.

setView(ViewExecutable $view)

Sets the executed view of this response.

getView()

Gets the executed view of this response.

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.

setView(ViewExecutable $view)

Sets the executed view of this response.

Parameters

ViewExecutable $view

The View executed on this ajax request.

ViewExecutable getView()

Gets the executed view of this response.

Return Value

ViewExecutable

The View executed on this ajax request.