class BaseCommand

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Ajax/BaseCommand.php \Drupal\Core\Ajax\BaseCommand
  2. 10 core/lib/Drupal/Core/Ajax/BaseCommand.php \Drupal\Core\Ajax\BaseCommand
  3. 11.x core/lib/Drupal/Core/Ajax/BaseCommand.php \Drupal\Core\Ajax\BaseCommand

Base command that only exists to simplify AJAX commands.

Hierarchy

Expanded class hierarchy of BaseCommand

6 files declare their use of BaseCommand
EntitySavedCommand.php in core/modules/quickedit/src/Ajax/EntitySavedCommand.php
FieldFormCommand.php in core/modules/quickedit/src/Ajax/FieldFormCommand.php
FieldFormSavedCommand.php in core/modules/quickedit/src/Ajax/FieldFormSavedCommand.php
FieldFormValidationErrorsCommand.php in core/modules/quickedit/src/Ajax/FieldFormValidationErrorsCommand.php
GetUntransformedTextCommand.php in core/modules/quickedit/src/Ajax/GetUntransformedTextCommand.php

... See full list

File

core/lib/Drupal/Core/Ajax/BaseCommand.php, line 8

Namespace

Drupal\Core\Ajax
View source
class BaseCommand implements CommandInterface {
    
    /**
     * The name of the command.
     *
     * @var string
     */
    protected $command;
    
    /**
     * The data to pass on to the client side.
     *
     * @var string
     */
    protected $data;
    
    /**
     * Constructs a BaseCommand object.
     *
     * @param string $command
     *   The name of the command.
     * @param string $data
     *   The data to pass on to the client side.
     */
    public function __construct($command, $data) {
        $this->command = $command;
        $this->data = $data;
    }
    
    /**
     * {@inheritdoc}
     */
    public function render() {
        return [
            'command' => $this->command,
            'data' => $this->data,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
BaseCommand::$command protected property The name of the command.
BaseCommand::$data protected property The data to pass on to the client side.
BaseCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render 1
BaseCommand::__construct public function Constructs a BaseCommand object. 6

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.