You are here

protected function ReplaceImageTrait::validateArguments in Image Effects 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/ReplaceImageTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\ReplaceImageTrait::validateArguments()
  2. 8.2 src/Plugin/ImageToolkit/Operation/ReplaceImageTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\ReplaceImageTrait::validateArguments()

File

src/Plugin/ImageToolkit/Operation/ReplaceImageTrait.php, line 26

Class

ReplaceImageTrait
Base trait for replace image operations.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation

Code

protected function validateArguments(array $arguments) {

  // Ensure replacement_image is an expected ImageInterface object.
  if (!$arguments['replacement_image'] instanceof ImageInterface) {
    throw new \InvalidArgumentException("Replacement image passed to the 'replace_image' operation is invalid");
  }

  // Ensure replacement_image is a valid image.
  if (!$arguments['replacement_image']
    ->isValid()) {
    $source = $arguments['replacement_image']
      ->getSource();
    throw new \InvalidArgumentException("Invalid image at {$source}");
  }
  return $arguments;
}