Basic.php in Image Effects 8.2
File
src/Plugin/image_effects/ImageSelector/Basic.php
View source
<?php
namespace Drupal\image_effects\Plugin\image_effects\ImageSelector;
use Drupal\Core\Form\FormStateInterface;
use Drupal\image_effects\Plugin\ImageEffectsPluginBase;
class Basic extends ImageEffectsPluginBase {
public function selectionElement(array $options = []) {
return array_merge([
'#type' => 'textfield',
'#title' => $this
->t('Image URI/path'),
'#description' => $this
->t('An URI, an absolute path, or a relative path. Relative paths will be resolved relative to the Drupal installation directory.'),
'#element_validate' => [
[
$this,
'validateSelectorUri',
],
],
], $options);
}
public function validateSelectorUri($element, FormStateInterface $form_state, $form) {
if (!empty($element['#value'])) {
if (!file_exists($element['#value'])) {
$form_state
->setErrorByName(implode('][', $element['#parents']), $this
->t('The file does not exist.'));
}
}
}
}
Classes
Name |
Description |
Basic |
Basic image selector plugin. |