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