ReplaceImageTrait.php in Image Effects 8.3
File
src/Plugin/ImageToolkit/Operation/ReplaceImageTrait.php
View source
<?php
namespace Drupal\image_effects\Plugin\ImageToolkit\Operation;
use Drupal\Core\Image\ImageInterface;
trait ReplaceImageTrait {
protected function arguments() {
return [
'replacement_image' => [
'description' => 'The image to be used to replace current one.',
],
];
}
protected function validateArguments(array $arguments) {
if (!$arguments['replacement_image'] instanceof ImageInterface) {
throw new \InvalidArgumentException("Replacement image passed to the 'replace_image' operation is invalid");
}
if (!$arguments['replacement_image']
->isValid()) {
$source = $arguments['replacement_image']
->getSource();
throw new \InvalidArgumentException("Invalid image at {$source}");
}
return $arguments;
}
}