You are here

public static function Crop::cropExists in Crop API 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Crop.php \Drupal\crop\Entity\Crop::cropExists()

Checks whether crop exists for an image.

Parameters

string $uri: URI of image to check for.

string $type: (Optional) Type of crop. Function will check across all available types if omitted.

Return value

bool Boolean TRUE if crop exists and FALSE if not.

Overrides CropInterface::cropExists

2 calls to Crop::cropExists()
CropCRUDTest::testCropSave in tests/src/Kernel/CropCRUDTest.php
Tests crop save.
CropFunctionalTest::doTestFileUriAlter in tests/src/Functional/CropFunctionalTest.php
Asserts a shortened hash is added to the file URI.

File

src/Entity/Crop.php, line 125

Class

Crop
Defines the crop entity class.

Namespace

Drupal\crop\Entity

Code

public static function cropExists($uri, $type = NULL) {
  $query = \Drupal::entityQuery('crop')
    ->condition('uri', $uri);
  if ($type) {
    $query
      ->condition('type', $type);
  }
  return (bool) $query
    ->execute();
}