class UpdateBuildIdCommand
Same name in other branches
- 9 core/lib/Drupal/Core/Ajax/UpdateBuildIdCommand.php \Drupal\Core\Ajax\UpdateBuildIdCommand
- 8.9.x core/lib/Drupal/Core/Ajax/UpdateBuildIdCommand.php \Drupal\Core\Ajax\UpdateBuildIdCommand
- 11.x core/lib/Drupal/Core/Ajax/UpdateBuildIdCommand.php \Drupal\Core\Ajax\UpdateBuildIdCommand
Ajax command for updating the form build ID.
Used for updating the value of a hidden form_build_id input element on a form. It requires the form passed in to have keys for both the old build ID in #build_id_old and the new build ID in #build_id.
The primary use case for this Ajax command is to serve a new build ID to a form served from the cache to an anonymous user, preventing one anonymous user from accessing the form state of another anonymous user on Ajax enabled forms.
This command is implemented by Drupal.AjaxCommands.prototype.update_build_id() defined in misc/ajax.js.
Hierarchy
- class \Drupal\Core\Ajax\UpdateBuildIdCommand implements \Drupal\Core\Ajax\CommandInterface
Expanded class hierarchy of UpdateBuildIdCommand
Related topics
2 files declare their use of UpdateBuildIdCommand
- AjaxCommandsTest.php in core/
tests/ Drupal/ Tests/ Core/ Ajax/ AjaxCommandsTest.php - FormAjaxResponseBuilder.php in core/
lib/ Drupal/ Core/ Form/ FormAjaxResponseBuilder.php
File
-
core/
lib/ Drupal/ Core/ Ajax/ UpdateBuildIdCommand.php, line 22
Namespace
Drupal\Core\AjaxView source
class UpdateBuildIdCommand implements CommandInterface {
/**
* Old build id.
*
* @var string
*/
protected $old;
/**
* New build id.
*
* @var string
*/
protected $new;
/**
* Constructs an UpdateBuildIdCommand object.
*
* @param string $old
* The old build_id.
* @param string $new
* The new build_id.
*/
public function __construct($old, $new) {
$this->old = $old;
$this->new = $new;
}
/**
* {@inheritdoc}
*/
public function render() {
return [
'command' => 'update_build_id',
'old' => $this->old,
'new' => $this->new,
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
UpdateBuildIdCommand::$new | protected | property | New build id. | |
UpdateBuildIdCommand::$old | protected | property | Old build id. | |
UpdateBuildIdCommand::render | public | function | Return an array to be run through json_encode and sent to the client. | Overrides CommandInterface::render |
UpdateBuildIdCommand::__construct | public | function | Constructs an UpdateBuildIdCommand object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.