comparison core/lib/Drupal/Core/Ajax/UpdateBuildIdCommand.php @ 0:4c8ae668cc8c

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