Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/Ajax/UpdateBuildIdCommand.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\Ajax; |
Chris@0 | 4 |
Chris@0 | 5 /** |
Chris@0 | 6 * AJAX command for updating the value of a hidden form_build_id input element |
Chris@0 | 7 * on a form. It requires the form passed in to have keys for both the old build |
Chris@0 | 8 * ID in #build_id_old and the new build ID in #build_id. |
Chris@0 | 9 * |
Chris@0 | 10 * The primary use case for this Ajax command is to serve a new build ID to a |
Chris@0 | 11 * form served from the cache to an anonymous user, preventing one anonymous |
Chris@0 | 12 * user from accessing the form state of another anonymous user on Ajax enabled |
Chris@0 | 13 * forms. |
Chris@0 | 14 * |
Chris@0 | 15 * This command is implemented by |
Chris@0 | 16 * Drupal.AjaxCommands.prototype.update_build_id() defined in misc/ajax.js. |
Chris@0 | 17 *O |
Chris@0 | 18 * @ingroup ajax |
Chris@0 | 19 */ |
Chris@0 | 20 class UpdateBuildIdCommand implements CommandInterface { |
Chris@0 | 21 |
Chris@0 | 22 /** |
Chris@0 | 23 * Old build id. |
Chris@0 | 24 * |
Chris@0 | 25 * @var string |
Chris@0 | 26 */ |
Chris@0 | 27 protected $old; |
Chris@0 | 28 |
Chris@0 | 29 /** |
Chris@0 | 30 * New build id. |
Chris@0 | 31 * |
Chris@0 | 32 * @var string |
Chris@0 | 33 */ |
Chris@0 | 34 protected $new; |
Chris@0 | 35 |
Chris@0 | 36 /** |
Chris@0 | 37 * Constructs a UpdateBuildIdCommand object. |
Chris@0 | 38 * |
Chris@0 | 39 * @param string $old |
Chris@0 | 40 * The old build_id. |
Chris@0 | 41 * @param string $new |
Chris@0 | 42 * The new build_id. |
Chris@0 | 43 */ |
Chris@0 | 44 public function __construct($old, $new) { |
Chris@0 | 45 $this->old = $old; |
Chris@0 | 46 $this->new = $new; |
Chris@0 | 47 } |
Chris@0 | 48 |
Chris@0 | 49 /** |
Chris@0 | 50 * {@inheritdoc} |
Chris@0 | 51 */ |
Chris@0 | 52 public function render() { |
Chris@0 | 53 return [ |
Chris@0 | 54 'command' => 'update_build_id', |
Chris@0 | 55 'old' => $this->old, |
Chris@0 | 56 'new' => $this->new, |
Chris@0 | 57 ]; |
Chris@0 | 58 } |
Chris@0 | 59 |
Chris@0 | 60 } |