Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphsBehaviorInterface.php
1 <?php
2
3 namespace Drupal\paragraphs;
4
5 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Component\Plugin\ConfigurablePluginInterface;
9 use Drupal\paragraphs\Entity\Paragraph;
10 use Drupal\paragraphs\Entity\ParagraphsType;
11
12 /**
13  * Provides an interface defining a paragraph behavior.
14  *
15  * A paragraph behavior plugin adds extra functionality to the paragraph such as
16  * adding properties and attributes, it can also add extra classes to the render
17  * elements so extra styling can be applied.
18  */
19 interface ParagraphsBehaviorInterface extends PluginFormInterface, ConfigurablePluginInterface {
20
21   /**
22    * Builds a behavior perspective for each paragraph based on its type.
23    *
24    * This method is responsible for building the behavior form for each
25    * Paragraph so the user can set special attributes and properties.
26    *
27    * @param \Drupal\paragraphs\ParagraphInterface $paragraph
28    *   The paragraph.
29    * @param array $form
30    *   An associative array containing the initial structure of the plugin form.
31    * @param \Drupal\Core\Form\FormStateInterface $form_state
32    *   The current state of the form.
33    *
34    * @return array
35    *   The fields build array that the plugin creates.
36    */
37   public function buildBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state);
38
39   /**
40    * Validates the behavior fields form.
41    *
42    * This method is responsible for validating the data in the behavior fields
43    * form and displaying validation messages.
44    *
45    * @param \Drupal\paragraphs\ParagraphInterface $paragraph
46    *   The paragraph.
47    * @param array $form
48    *   An associative array containing the initial structure of the plugin form.
49    * @param \Drupal\Core\Form\FormStateInterface $form_state
50    *   The current state of the form.
51    */
52   public function validateBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state);
53
54   /**
55    * Submit the values taken from the form to store the values.
56    *
57    * This method is responsible for submitting the data and saving it in the
58    * paragraphs entity.
59    *
60    * @param \Drupal\paragraphs\ParagraphInterface $paragraph
61    *   The paragraph.
62    * @param array $form
63    *   An associative array containing the initial structure of the plugin form.
64    * @param \Drupal\Core\Form\FormStateInterface $form_state
65    *   The current state of the form.
66    */
67   public function submitBehaviorForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state);
68
69   /**
70    * Adds a default set of helper variables for preprocessors and templates.
71    *
72    * This preprocess function is the first in the sequence of preprocessing
73    * functions that are called when preparing variables of a paragraph.
74    *
75    * @param array $variables
76    *   An associative array containing:
77    *   - elements: An array of elements to display in view mode.
78    *   - paragraph: The paragraph object.
79    *   - view_mode: The view mode.
80    */
81   public function preprocess(&$variables);
82
83   /**
84    * Extends the paragraph render array with behavior.
85    *
86    * @param array &$build
87    *   A renderable array representing the paragraph. The module may add
88    *   elements to $build prior to rendering. The structure of $build is a
89    *   renderable array as expected by drupal_render().
90    * @param \Drupal\paragraphs\Entity\Paragraph $paragraph
91    *   The paragraph.
92    * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
93    *   The entity view display holding the display options configured for the
94    *   entity components.
95    * @param string $view_mode
96    *   The view mode the entity is rendered in.
97    *
98    * @return array
99    *   A render array provided by the plugin.
100    */
101   public function view(array &$build, Paragraph $paragraph, EntityViewDisplayInterface $display, $view_mode);
102
103   /**
104    * Returns if the plugin can be used for the provided Paragraphs type.
105    *
106    * @param \Drupal\paragraphs\Entity\ParagraphsType $paragraphs_type
107    *   The Paragraphs type entity that should be checked.
108    *
109    * @return bool
110    *   TRUE if the formatter can be used, FALSE otherwise.
111    */
112   public static function isApplicable(ParagraphsType $paragraphs_type);
113
114   /**
115    * Returns a short summary for the current behavior settings.
116    *
117    * @param \Drupal\paragraphs\Entity\Paragraph $paragraph
118    *   The paragraph.
119    *
120    * @return string[]
121    *   The plugin settings.
122    */
123   public function settingsSummary(Paragraph $paragraph);
124
125   /**
126    * Returns list of field names for the given paragraph type and field type.
127    *
128    *
129    * @param \Drupal\paragraphs\Entity\ParagraphsType $paragraphs_type
130    *   The paragraphs type entity.
131    * @param string $field_type
132    *   (optional) Field type to check for existence. If field type is not
133    *   provided, returns all entity fields.
134    *
135    * @return string[]
136    *   The list of field labels keyed by their field name.
137    */
138   public function getFieldNameOptions(ParagraphsType $paragraphs_type, $field_type = NULL);
139
140 }