Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / web / modules / contrib / crop / src / CropInterface.php
1 <?php
2
3 namespace Drupal\crop;
4
5 use Drupal\Core\Entity\ContentEntityInterface;
6 use Drupal\image\ImageStyleInterface;
7
8 /**
9  * Provides an interface defining the crop entity.
10  */
11 interface CropInterface extends ContentEntityInterface {
12
13   /**
14    * Gets position of crop's center.
15    *
16    * @return array
17    *   Array with two keys (x, y) and center coordinates as values.
18    */
19   public function position();
20
21   /**
22    * Sets position of crop's center.
23    *
24    * @param int $x
25    *   X coordinate of the crop's center.
26    * @param int $y
27    *   Y coordinate of the crop's center.
28    *
29    * @return \Drupal\crop\CropInterface
30    *   Crop object this is being called on.
31    */
32   public function setPosition($x, $y);
33
34   /**
35    * Gets crop's size.
36    *
37    * @return array
38    *   Array with two keys (width, height) each side dimensions as values.
39    */
40   public function size();
41
42   /**
43    * Sets crop's size.
44    *
45    * @param int $width
46    *   Crop's width.
47    * @param int $height
48    *   Crop's height.
49    *
50    * @return \Drupal\crop\CropInterface
51    *   Crop object this is being called on.
52    */
53   public function setSize($width, $height);
54
55   /**
56    * Gets crop anchor (top-left corner of crop area).
57    *
58    * @return array
59    *   Array with two keys (x, y) and anchor coordinates as values.
60    */
61   public function anchor();
62
63   /**
64    * Gets entity provider for the crop.
65    *
66    * @return \Drupal\crop\EntityProviderInterface
67    *   Entity provider.
68    *
69    * @throws \Drupal\crop\EntityProviderNotFoundException
70    *   Thrown if entity provider not found.
71    */
72   public function provider();
73
74   /**
75    * Checks whether crop exists for an image.
76    *
77    * @param string $uri
78    *   URI of image to check for.
79    * @param string $type
80    *   (Optional) Type of crop. Function will check across all available types
81    *   if omitted.
82    *
83    * @return bool
84    *   Boolean TRUE if crop exists and FALSE if not.
85    */
86   public static function cropExists($uri, $type = NULL);
87
88   /**
89    * Loads crop based on image URI and crop type.
90    *
91    * @param string $uri
92    *   URI of the image.
93    * @param string $type
94    *   Crop type.
95    *
96    * @return \Drupal\crop\CropInterface|null
97    *   Crop entity or NULL if crop doesn't exist.
98    */
99   public static function findCrop($uri, $type);
100
101   /**
102    * Retrieve crop from given image style.
103    *
104    * @param string $uri
105    *   URI of the image.
106    * @param \Drupal\image\ImageStyleInterface $image_style
107    *   The image style.
108    *
109    * @return \Drupal\crop\CropInterface|null
110    *   Crop entity used by effect 'crop_crop' or NULL if crop doesn't exist.
111    */
112   public static function getCropFromImageStyle($uri, ImageStyleInterface $image_style);
113
114 }