Version 1
[yaffs-website] / web / core / modules / quickedit / src / Ajax / FieldFormSavedCommand.php
1 <?php
2
3 namespace Drupal\quickedit\Ajax;
4
5 use Drupal\Core\Ajax\BaseCommand;
6
7 /**
8  * AJAX command to indicate a field was saved into PrivateTempStore without
9  * validation errors and pass the rerendered field to Quick Edit's JavaScript
10  * app.
11  */
12 class FieldFormSavedCommand extends BaseCommand {
13
14   /**
15    * The same re-rendered edited field, but in different view modes.
16    *
17    * @var array
18    */
19   protected $other_view_modes;
20
21   /**
22    * Constructs a FieldFormSavedCommand object.
23    *
24    * @param string $data
25    *   The re-rendered edited field to pass on to the client side.
26    * @param array $other_view_modes
27    *   The same re-rendered edited field, but in different view modes, for other
28    *   instances of the same field on the user's page. Keyed by view mode.
29    */
30   public function __construct($data, $other_view_modes = []) {
31     parent::__construct('quickeditFieldFormSaved', $data);
32
33     $this->other_view_modes = $other_view_modes;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function render() {
40     return [
41       'command' => $this->command,
42       'data' => $this->data,
43       'other_view_modes' => $this->other_view_modes,
44     ];
45   }
46
47 }