Paragraphs Editor
GeneratorInterface.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
9 /**
10  * An interface for widget binder data generators.
11  *
12  * Generators are responsible for producing compiled widget binder models that
13  * will be sent to the client. They can also generate other temporary data for
14  * rendering that can be accessed through the compiler state. In general, each
15  * generator should be responsible for generating one type of model or render
16  * helper object.
17  */
18 interface GeneratorInterface {
19 
20  /**
21  * Provides a unique id for the generator.
22  *
23  * The id should be a single word string, preferably specifying the type of
24  * model or object it generates.
25  */
26  public function id();
27 
28  /**
29  * Initializes the generator before any processing has taken place.
30  *
31  * This should be used to prime the compiler state to prepare for generation.
32  *
33  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
34  * The compiled data to add models to.
35  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
36  * The compiler state to be initialized.
37  * @param \Drupal\paragraphs\ParagraphInterface $paragraph
38  * The paragraph being compiled.
39  */
40  public function initialize(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph);
41 
42  /**
43  * Visits a paragraph in the content tree.
44  *
45  * This is called before rendering for each paragraph, and recursively for
46  * each child paragraph. Paragraphs are processed top-down.
47  *
48  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
49  * The compiled data to add models to.
50  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
51  * The compiler state.
52  * @param \Drupal\paragraphs\ParagraphInterface $paragraph
53  * The paragraph to process.
54  */
55  public function processParagraph(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph);
56 
57  /**
58  * Visits a paragraph field in the content tree.
59  *
60  * This is called before rendering for each paragraph entity reference field,
61  * and recursively for each child field. Fields are processed top-down.
62  *
63  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
64  * The compiled data to add models to.
65  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
66  * The compiler state.
67  * @param \Drupal\Core\Field\EntityReferenceFieldItemListInterface $items
68  * The field items to process.
69  * @param bool $is_editor_field
70  * TRUE if this is a paragraphs editor field, FALSE if this is a plain
71  * paragraphs field.
72  */
73  public function processField(WidgetBinderData $data, WidgetBinderDataCompilerState $state, EntityReferenceFieldItemListInterface $items, $is_editor_field);
74 
75  /**
76  * Visits a paragraph in the content tree.
77  *
78  * This is called before rendering for each paragraph, and recursively for
79  * each child paragraph. Paragraphs are processed bottom-up.
80  *
81  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
82  * The compiled data to add models to.
83  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
84  * The compiler state.
85  * @param \Drupal\paragraphs\ParagraphInterface $paragraph
86  * The paragraph to process.
87  */
88  public function postprocessParagraph(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph);
89 
90  /**
91  * Visits a paragraph field in the content tree.
92  *
93  * This is called before rendering for each paragraph entity reference field,
94  * and recursively for each child field. Fields are processed bottom-up.
95  *
96  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
97  * The compiled data to add models to.
98  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
99  * The compiler state.
100  * @param \Drupal\Core\Field\EntityReferenceFieldItemListInterface $items
101  * The field items to process.
102  * @param bool $is_editor_field
103  * TRUE if this is a paragraphs editor field, FALSE if this is a plain
104  * paragraphs field.
105  */
106  public function postprocessField(WidgetBinderData $data, WidgetBinderDataCompilerState $state, EntityReferenceFieldItemListInterface $items, $is_editor_field);
107 
108  /**
109  * Called after a compiler finishes with the rendered markup.
110  *
111  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderData $data
112  * The compiled data to add models to.
113  * @param \Drupal\paragraphs_editor\WidgetBinder\WidgetBinderDataCompilerState $state
114  * The compiler state.
115  * @param \Drupal\Core\Render\RenderContext $render_context
116  * The Drupal render context containing the bubbled metadata for the
117  * rendered item.
118  * @param string $markup
119  * The rendered markup for the item.
120  */
121  public function complete(WidgetBinderData $data, WidgetBinderDataCompilerState $state, RenderContext $render_context, $markup);
122 
123 }
processParagraph(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph)
initialize(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph)
complete(WidgetBinderData $data, WidgetBinderDataCompilerState $state, RenderContext $render_context, $markup)
processField(WidgetBinderData $data, WidgetBinderDataCompilerState $state, EntityReferenceFieldItemListInterface $items, $is_editor_field)
postprocessParagraph(WidgetBinderData $data, WidgetBinderDataCompilerState $state, ParagraphInterface $paragraph)
postprocessField(WidgetBinderData $data, WidgetBinderDataCompilerState $state, EntityReferenceFieldItemListInterface $items, $is_editor_field)