EncipherImageEffect.php in Imagick 8
File
src/Plugin/ImageEffect/EncipherImageEffect.php
View source
<?php
namespace Drupal\imagick\Plugin\ImageEffect;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Image\ImageInterface;
use Drupal\image\ConfigurableImageEffectBase;
class EncipherImageEffect extends ConfigurableImageEffectBase {
public function applyEffect(ImageInterface $image) {
if (!$image
->apply('encipher', $this->configuration)) {
$this->logger
->error('Image encipher failed using the %toolkit toolkit on %path (%mimetype)', [
'%toolkit' => $image
->getToolkitId(),
'%path' => $image
->getSource(),
'%mimetype' => $image
->getMimeType(),
]);
return FALSE;
}
return TRUE;
}
public function defaultConfiguration() {
return [
'password' => '',
];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['password'] = [
'#type' => 'textfield',
'#title' => $this
->t('Password to encrypt the image'),
'#default_value' => $this->configuration['password'],
];
return $form;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration['password'] = $form_state
->getValue('password');
}
}