Paragraphs Editor
DeliverWidgetBinderData.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 /**
9  * Ajax command for delivering widget binder model collections to the client.
10  */
11 class DeliverWidgetBinderData implements CommandInterface {
12 
13  /**
14  * The module name that will trigger the appropriate widget binder instance.
15  *
16  * @var string
17  */
18  protected $moduleName;
19 
20  /**
21  * The widget binder data models to be delivered.
22  *
23  * @var \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData
24  */
25  protected $data;
26 
27  /**
28  * Creates a DeliverWidgetBinderData command.
29  *
30  * @param string $module_name
31  * The module name implementing the editor integration.
32  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
33  * The data collection to deliver.
34  */
35  public function __construct($module_name, WidgetBinderData $data) {
36  $this->moduleName = $module_name;
37  $this->data = $data;
38  }
39 
40  /**
41  * {@inheritdoc}
42  */
43  public function render() {
44  $command = [
45  'command' => 'paragraphs_editor_data',
46  'module' => $this->moduleName,
47  ] + $this->data->toArray();
48  return $command;
49  }
50 
51 }