Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / image_widget_crop / src / ImageWidgetCropInterface.php
1 <?php
2
3 namespace Drupal\image_widget_crop;
4
5 use Drupal\Core\Entity\EntityInterface;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\crop\Entity\Crop;
8 use Drupal\crop\Entity\CropType;
9 use Drupal\image\Entity\ImageStyle;
10
11 /**
12  * Defines the interface for ImageWidgetCropManager calculation class service.
13  */
14 interface ImageWidgetCropInterface {
15
16   /**
17    * Create new crop entity with user properties.
18    *
19    * @param array $properties
20    *   All properties returned by the crop plugin (js),
21    *   and the size of thumbnail image.
22    * @param array|mixed $field_value
23    *   An array of values for the contained properties of image_crop widget.
24    * @param \Drupal\crop\Entity\CropType $crop_type
25    *   The entity CropType.
26    */
27   public function applyCrop(array $properties, $field_value, CropType $crop_type);
28
29   /**
30    * Update old crop with new properties choose in UI.
31    *
32    * @param array $properties
33    *   All properties returned by the crop plugin (js),
34    *   and the size of thumbnail image.
35    * @param array|mixed $field_value
36    *   An array of values contain properties of image_crop widget.
37    * @param \Drupal\crop\Entity\CropType $crop_type
38    *   The entity CropType.
39    */
40   public function updateCrop(array $properties, $field_value, CropType $crop_type);
41
42   /**
43    * Save the crop when this crop not exist.
44    *
45    * @param double[] $crop_properties
46    *   The properties of the crop applied to the original image (dimensions).
47    * @param array|mixed $field_value
48    *   An array of values for the contained properties of image_crop widget.
49    * @param \Drupal\crop\Entity\CropType $crop_type
50    *   The entity CropType.
51    * @param bool $notify
52    *   Show notification after actions (default TRUE).
53    */
54   public function saveCrop(
55     array $crop_properties,
56     $field_value,
57     CropType $crop_type,
58     $notify = TRUE
59   );
60
61   /**
62    * Delete the crop when user delete it.
63    *
64    * @param string $file_uri
65    *   Uri of image uploaded by user.
66    * @param \Drupal\crop\Entity\CropType $crop_type
67    *   The CropType object.
68    * @param int $file_id
69    *   Id of image uploaded by user.
70    */
71   public function deleteCrop($file_uri, CropType $crop_type, $file_id);
72
73   /**
74    * Get center of crop selection.
75    *
76    * @param int[] $axis
77    *   Coordinates of x-axis & y-axis.
78    * @param array $crop_selection
79    *   Coordinates of crop selection (width & height).
80    *
81    * @return arraystringinteger
82    *   Coordinates (x-axis & y-axis) of crop selection zone.
83    */
84   public function getAxisCoordinates(array $axis, array $crop_selection);
85
86   /**
87    * Get the size and position of the crop.
88    *
89    * @param array $field_values
90    *   The original values of image.
91    * @param array $properties
92    *   The original height of image.
93    *
94    * @return array
95    *   The data dimensions (width & height) into this ImageStyle or,
96    *   empty array is the image isn't a valid file.
97    */
98   public function getCropOriginalDimension(array $field_values, array $properties);
99
100   /**
101    * Get one effect instead of ImageStyle.
102    *
103    * @param \Drupal\image\Entity\ImageStyle $image_style
104    *   The ImageStyle to get data.
105    * @param string $data_type
106    *   The type of data needed in current ImageStyle.
107    *
108    * @return mixed|null
109    *   The effect data in current ImageStyle.
110    */
111   public function getEffectData(ImageStyle $image_style, $data_type);
112
113   /**
114    * Get the imageStyle using this crop_type.
115    *
116    * @param string $crop_type_name
117    *   The id of the current crop_type entity.
118    *
119    * @return array
120    *   All imageStyle used by this crop_type.
121    */
122   public function getImageStylesByCrop($crop_type_name);
123
124   /**
125    * Apply different operation on ImageStyles.
126    *
127    * @param array $image_styles
128    *   All ImageStyles used by this cropType.
129    * @param string $file_uri
130    *   Uri of image uploaded by user.
131    * @param bool $create_derivative
132    *   Boolean to create an derivative of the image uploaded.
133    */
134   public function imageStylesOperations(array $image_styles, $file_uri, $create_derivative = FALSE);
135
136   /**
137    * Update existent crop entity properties.
138    *
139    * @param \Drupal\crop\Entity\Crop $crop
140    *   The crop object loaded.
141    * @param array $crop_properties
142    *   The machine name of ImageStyle.
143    */
144   public function updateCropProperties(Crop $crop, array $crop_properties);
145
146   /**
147    * Load all crop using the ImageStyles.
148    *
149    * @param array $image_styles
150    *   All ImageStyle for this current CROP.
151    * @param \Drupal\crop\Entity\CropType $crop_type
152    *   The entity CropType.
153    * @param string $file_uri
154    *   Uri of uploded file.
155    *
156    * @return array
157    *   All crop used this ImageStyle.
158    */
159   public function loadImageStyleByCrop(array $image_styles, CropType $crop_type, $file_uri);
160
161   /**
162    * Compare crop zone properties when user saved one crop.
163    *
164    * @param array $crop_properties
165    *   The crop properties after saved the form.
166    * @param array $old_crop
167    *   The crop properties save in this crop entity,
168    *   Only if this crop already exist.
169    *
170    * @return bool
171    *   Return true if properties is not identical.
172    */
173   public function cropHasChanged(array $crop_properties, array $old_crop);
174
175   /**
176    * Verify if the crop is used by a ImageStyle.
177    *
178    * @param string[] $crop_list
179    *   The list of existent Crop Type.
180    *
181    * @return arrayinteger
182    *   The list of Crop Type filtred.
183    */
184   public function getAvailableCropType(array $crop_list);
185
186   /**
187    * Get All sizes properties of the crops for an file.
188    *
189    * @param \Drupal\crop\Entity\Crop $crop
190    *   All crops attached to this file based on URI.
191    *
192    * @return arrayarray
193    *   Get all crop zone properties (x, y, height, width),
194    */
195   public static function getCropProperties(Crop $crop);
196
197   /**
198    * Fetch all fields FileField and use "image_crop" element on an entity.
199    *
200    * @param \Drupal\Core\Entity\EntityInterface $entity
201    *   The entity object.
202    */
203   public function buildCropToEntity(EntityInterface $entity);
204
205   /**
206    * Fetch all form elements using image_crop element.
207    *
208    * @param \Drupal\Core\Form\FormStateInterface $form_state
209    *   The current state of the form.
210    */
211   public function buildCropToForm(FormStateInterface $form_state);
212
213 }