diff -u b/src/CropStorage.php b/src/CropStorage.php --- b/src/CropStorage.php +++ b/src/CropStorage.php @@ -26,7 +26,8 @@ $query->range(0, 1); - return $query->execute()->fetchField(); + $cid = $query->execute()->fetchField(); + return $cid ? $this->load($cid) : NULL; } } diff -u b/src/CropStorageInterface.php b/src/CropStorageInterface.php --- b/src/CropStorageInterface.php +++ b/src/CropStorageInterface.php @@ -19,8 +19,8 @@ * @param string $type * Crop type. * - * @return int - * An integer represent crop id of given uri. + * @return \Drupal\crop\CropInterface|null + * A Crop object or NULL if nothing match with our search. */ public function getCrop($uri, $type); diff -u b/src/Entity/Crop.php b/src/Entity/Crop.php --- b/src/Entity/Crop.php +++ b/src/Entity/Crop.php @@ -129,8 +129,7 @@ * {@inheritdoc} */ public static function findCrop($uri, $type) { - $cid = \Drupal::entityTypeManager()->getStorage('crop')->getCrop($uri, $type); - return $cid ? \Drupal::entityTypeManager()->getStorage('crop')->load($cid) : NULL; + return \Drupal::entityTypeManager()->getStorage('crop')->getCrop($uri, $type); } /**