Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / crop / src / CropStorage.php
index 4f08ac4aa4fa32d59766b914a0ba8e25db229231..ec84b5e7a3e00e45c329af889b8bdd68f0e3ea18 100644 (file)
@@ -5,8 +5,29 @@ namespace Drupal\crop;
 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
 
 /**
- * Image crop storage class.
+ * Defines the storage handler class for image crop storage.
+ *
+ * This extends the Drupal\Core\Entity\Sql\SqlContentEntityStorage class,
+ * adding required special handling for comment entities.
  */
 class CropStorage extends SqlContentEntityStorage implements CropStorageInterface {
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getCrop($uri, $type) {
+    $query = $this->database->select('crop_field_data', 'cfd');
+    $query->addField('cfd', 'cid');
+    $query->condition('cfd.uri', $uri, 'LIKE');
+
+    if ($type) {
+      $query->condition('cfd.type', $type);
+    }
+
+    $query->range(0, 1);
+
+    $cid = $query->execute()->fetchField();
+    return $cid ? $this->load($cid) : NULL;
+  }
+
 }