Further changes for the Use cases on the live site.
[yaffs-website] / web / core / modules / responsive_image / src / ResponsiveImageStyleInterface.php
1 <?php
2
3 namespace Drupal\responsive_image;
4
5 use Drupal\Core\Config\Entity\ConfigEntityInterface;
6
7 /**
8  * Provides an interface defining a responsive_image mapping entity.
9  */
10 interface ResponsiveImageStyleInterface extends ConfigEntityInterface {
11
12   /**
13    * The machine name for the empty image breakpoint image style option.
14    */
15   const EMPTY_IMAGE = '_empty image_';
16
17   /**
18    * The machine name for the original image breakpoint image style option.
19    */
20   const ORIGINAL_IMAGE = '_original image_';
21
22   /**
23    * Checks if there is at least one mapping defined.
24    *
25    * @return bool
26    *   Whether the entity has any image style mappings.
27    */
28   public function hasImageStyleMappings();
29
30   /**
31    * Returns the mappings of breakpoint ID and multiplier to image style.
32    *
33    * @return array[]
34    *   The image style mappings. Keyed by breakpoint ID then multiplier.
35    *   The value is the image style mapping array with following keys:
36    *     - image_mapping_type: Either 'image_style' or 'sizes'.
37    *     - image_mapping:
38    *       - If image_mapping_type is 'image_style', the image style ID.
39    *       - If image_mapping_type is 'sizes', an array with following keys:
40    *         - sizes: The value for the 'sizes' attribute.
41    *         - sizes_image_styles: The image styles to use for the 'srcset'
42    *           attribute.
43    *     - breakpoint_id: The breakpoint ID for this mapping.
44    *     - multiplier: The multiplier for this mapping.
45    */
46   public function getKeyedImageStyleMappings();
47
48   /**
49    * Returns the image style mappings for the responsive image style.
50    *
51    * @return array[]
52    *   An array of image style mappings. Each image style mapping array
53    *   contains the following keys:
54    *   - breakpoint_id
55    *   - multiplier
56    *   - image_mapping_type
57    *   - image_mapping
58    */
59   public function getImageStyleMappings();
60
61   /**
62    * Sets the breakpoint group for the responsive image style.
63    *
64    * @param string $breakpoint_group
65    *   The responsive image style breakpoint group.
66    *
67    * @return $this
68    */
69   public function setBreakpointGroup($breakpoint_group);
70
71   /**
72    * Returns the breakpoint group for the responsive image style.
73    *
74    * @return string
75    *   The breakpoint group.
76    */
77   public function getBreakpointGroup();
78
79   /**
80    * Sets the fallback image style for the responsive image style.
81    *
82    * @param string $fallback_image_style
83    *   The fallback image style ID.
84    *
85    * @return $this
86    */
87   public function setFallbackImageStyle($fallback_image_style);
88
89   /**
90    * Returns the fallback image style ID for the responsive image style.
91    *
92    * @return string
93    *   The fallback image style ID.
94    */
95   public function getFallbackImageStyle();
96
97   /**
98    * Gets the image style mapping for a breakpoint ID and multiplier.
99    *
100    * @param string $breakpoint_id
101    *   The breakpoint ID.
102    * @param string $multiplier
103    *   The multiplier.
104    *
105    * @return array|null
106    *   The image style mapping. NULL if the mapping does not exist.
107    *   The image style mapping has following keys:
108    *     - image_mapping_type: Either 'image_style' or 'sizes'.
109    *     - image_mapping:
110    *       - If image_mapping_type is 'image_style', the image style ID.
111    *       - If image_mapping_type is 'sizes', an array with following keys:
112    *         - sizes: The value for the 'sizes' attribute.
113    *         - sizes_image_styles: The image styles to use for the 'srcset'
114    *           attribute.
115    *     - breakpoint_id: The breakpoint ID for this image style mapping.
116    *     - multiplier: The multiplier for this image style mapping.
117    */
118   public function getImageStyleMapping($breakpoint_id, $multiplier);
119
120   /**
121    * Checks if there is at least one image style mapping defined.
122    *
123    * @param array $image_style_mapping
124    *   The image style mapping.
125    *
126    * @return bool
127    *   Whether the image style mapping is empty.
128    */
129   public static function isEmptyImageStyleMapping(array $image_style_mapping);
130
131   /**
132    * Adds a image style mapping to the responsive image configuration entity.
133    *
134    * @param string $breakpoint_id
135    *   The breakpoint ID.
136    * @param string $multiplier
137    *   The multiplier.
138    * @param array $image_style_mapping
139    *   The mapping image style mapping.
140    *
141    * @return $this
142    */
143   public function addImageStyleMapping($breakpoint_id, $multiplier, array $image_style_mapping);
144
145   /**
146    * Removes all image style mappings from the responsive image style.
147    *
148    * @return $this
149    */
150   public function removeImageStyleMappings();
151
152   /**
153    * Gets all the image styles IDs involved in the responsive image mapping.
154    *
155    * @return string[]
156    */
157   public function getImageStyleIds();
158
159 }