-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact_paragraphs.api.php
More file actions
38 lines (32 loc) · 957 Bytes
/
react_paragraphs.api.php
File metadata and controls
38 lines (32 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* @file
* Hooks specific to the react_paragraph module.
*
* @codeCoverageIgnore
*/
use Drupal\Field\Entity\FieldConfig;
/**
* Alter the info before being sent to the react widget.
*
* @codeCoverageIgnore
*
* @param array $info
* The array of data being passed to the react widget.
* @param array $field_element
* The form field element that is being transformed into react data.
* @param \Drupal\Field\Entity\FieldConfig $field_config
* The field configuration object.
*
* @see \Drupal\react_paragraphs\Plugin\rest\resource\ReactParagraphsResource::get
*/
function hook_react_paragraphs_form_field_data_alter(array &$info, array $field_element, FieldConfig $field_config) {
// Only alter data for the news_views view field.
if ($field_config->getName() !== "field_foo") {
return;
}
// Remove something.
unset($info['foo']['thing']);
// Add something.
$info['my_field']['values'] = ['foo', 'bar'];
}