summaryrefslogtreecommitdiffstats
path: root/core/modules/responsive_image/src/ResponsiveImageMappingInterface.php
blob: fd9b28be2262d210158555582ae787408e4e615c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php

/**
 * @file
 * Contains \Drupal\responsive_image\ResponsiveImageMappingInterface.
 */

namespace Drupal\responsive_image;

use Drupal\Core\Config\Entity\ConfigEntityInterface;

/**
 * Provides an interface defining a responsive_image mapping entity.
 */
interface ResponsiveImageMappingInterface extends ConfigEntityInterface {

  /**
   * Checks if there is at least one mapping defined.
   *
   * return bool
   *   Whether the entity has any responsive image mappings.
   */
  public function hasMappings();

  /**
   * Returns the mappings of breakpoint ID and multiplier to image style.
   *
   * @return array[]
   *   The responsive image mappings. Keyed by breakpoint ID then multiplier.
   *   The value is the image style ID.
   */
  public function getKeyedMappings();

  /**
   * Returns the mappings for the responsive image mapping.
   *
   * @return array[]
   *   An array responsive image mappings. Each responsive mapping array
   *   contains the following keys:
   *   - breakpoint_id
   *   - multiplier
   *   - image_style
   */
  public function getMappings();

  /**
   * Sets the breakpoint group for the responsive_image mapping.
   *
   * @param string $breakpoint_group
   *   The responsive image mapping breakpoint group.
   *
   * @return $this
   */
  public function setBreakpointGroup($breakpoint_group);

  /**
   * Returns the breakpoint group for the responsive image mapping.
   *
   * @return string
   *   The breakpoint group.
   */
  public function getBreakpointGroup();

  /**
   * Gets the image style ID for a breakpoint ID and multiplier.
   *
   * @param string $breakpoint_id
   *   The breakpoint ID.
   * @param string $multiplier
   *   The multiplier.
   *
   * @return string|null
   *   The image style ID. Null if the mapping does not exist.
   */
  public function getImageStyle($breakpoint_id, $multiplier);

  /**
   * Adds a mapping to the responsive image configuration entity.
   *
   * @param string $breakpoint_id
   *   The breakpoint ID.
   * @param string $multiplier
   *   The multiplier.
   * @param string $image_style
   *   The image style ID.
   *
   * @return $this
   */
  public function addMapping($breakpoint_id, $multiplier, $image_style);

  /**
   * Removes all mappings from the responsive image configuration entity.
   *
   * @return $this
   */
  public function removeMappings();

}