Paragraphs Editor
FieldValueManagerInterface.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 /**
9  * A service getting information about paragraphs fields.
10  */
12 
13  /**
14  * Gets a list of referenced entities in a paragraphs field.
15  *
16  * This function static caches loaded revisions. While calling
17  * referencedEntities directly on the items worked, it leads to performance
18  * problems in certain editor use cases.
19  *
20  * Drupal core currently does not sttic cache loaded entitiy revisions. This
21  * function should be deprecated when https://www.drupal.org/node/2620980
22  * is released.
23  *
24  * @param \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $items
25  * The paragraph field items to iterate over.
26  *
27  * @return \Drupal\paragraphs\ParagraphInterface[]
28  * An array of referenced paragraphs in the field.
29  */
30  public function getReferencedEntities(EntityReferenceRevisionsFieldItemList $items);
31 
32  /**
33  * Wraps a paragraphs editor field.
34  *
35  * @param \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $items
36  * The paragraph field items to wrap.
37  *
38  * @return \Drupal\paragraphs_editor\EditorFieldValue\FieldValueWrapperInterface
39  * The wrapped field.
40  */
41  public function wrapItems(EntityReferenceRevisionsFieldItemList $items);
42 
43  /**
44  * Sets the referenced entities on a paragraphs field.
45  *
46  * @param \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $items
47  * The field items to be updated.
48  * @param array $entities
49  * The entity values to set on the field items.
50  * @param bool $new_revision
51  * Set to true to create a new revision when the items are saved.
52  * @param string|null $langcode
53  * Overrides the language the paragraph will be saved in.
54  *
55  * @return \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList
56  * The updated items object.
57  */
58  public function setItems(EntityReferenceRevisionsFieldItemList $items, array $entities, $new_revision = FALSE, $langcode = NULL);
59 
60  /**
61  * Gets a list of paragraph types that can store markup.
62  *
63  * Text bundles are paragraph types that will be used to store the markup when
64  * editor content is saved. The first value in a paragraphs editor controlled
65  * field is always a text bundle. The remaining entities are referenced by the
66  * text bundle.
67  *
68  * @param array $allowed_bundles
69  * A list of bundles to filter the results by. Leave empty to return all
70  * results.
71  */
72  public function getTextBundles(array $allowed_bundles = []);
73 
74  /**
75  * Gets a list of text fields in a bundle that can store editor markup.
76  *
77  * @param string $bundle_name
78  * The bundle to read text fields from.
79  *
80  * @see getTextBundles
81  *
82  * @return string[]
83  * An array of text field names included in the bundle.
84  */
85  public function getTextFields($bundle_name);
86 
87  /**
88  * Determines whether a field is a paragraphs field.
89  *
90  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
91  * The field definition to check against.
92  *
93  * @return bool
94  * TRUE if it is a paragraphs field, FALSE otherwise.
95  */
96  public function isParagraphsField(FieldDefinitionInterface $field_definition);
97 
98  /**
99  * Determines whether a field is an editor-enabled paragraphs field.
100  *
101  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
102  * The field definition to check against.
103  *
104  * @return bool
105  * TRUE if it is a paragraphs editor field, FALSE otherwise.
106  */
107  public function isParagraphsEditorField(FieldDefinitionInterface $field_definition);
108 
109  /**
110  * Gets the an element definition by name.
111  *
112  * @param string $element_name
113  * The element name to get the definition for.
114  *
115  * @return array
116  * The element definition as defined in services.yml.
117  */
118  public function getElement($element_name);
119 
120  /**
121  * Gets an element attribute name based on a type.
122  *
123  * The name of the attribute should be wrapped in '<>' as it appears in
124  * services.yml.
125  *
126  * Example:
127  *
128  * @code
129  * $field_value_manager->getAttributeName('widget', '<context>');
130  * @endcode
131  *
132  * @param string $element_name
133  * The element name to get the attribute name for.
134  * @param string $attribute_name
135  * The name of the attribute to get the html name for.
136  *
137  * @return string
138  * The attribute name.
139  */
140  public function getAttributeName($element_name, $attribute_name);
141 
142  /**
143  * Gets a jQuery style attribute selector for an element.
144  *
145  * Note that this does not look at the selector entry for the element. The
146  * selector entry is used by the widget binder library to locate elements.
147  * Unfortunately this can cause issues with the back end DOM processor, so we
148  * ignore it.
149  *
150  * Instead, the selector here is built soley from the element tag and
151  * attribute names it requires.
152  *
153  * @param string $element_name
154  * The element name to get the selector for.
155  *
156  * @return string
157  * The generated selector.
158  */
159  public function getSelector($element_name);
160 
161 }
isParagraphsField(FieldDefinitionInterface $field_definition)
getReferencedEntities(EntityReferenceRevisionsFieldItemList $items)
wrapItems(EntityReferenceRevisionsFieldItemList $items)
isParagraphsEditorField(FieldDefinitionInterface $field_definition)
setItems(EntityReferenceRevisionsFieldItemList $items, array $entities, $new_revision=FALSE, $langcode=NULL)