You are here

CropStorage.php in Crop API 8

Same filename and directory in other branches
  1. 8.2 src/CropStorage.php

Namespace

Drupal\crop

File

src/CropStorage.php
View source
<?php

namespace Drupal\crop;

use Drupal\Core\Entity\Sql\SqlContentEntityStorage;

/**
 * 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;
  }

}

Classes

Namesort descending Description
CropStorage Defines the storage handler class for image crop storage.