You are here

public function Dropdown::validateSelectorUri in Image Effects 8

Same name in this branch
  1. 8 src/Plugin/image_effects/FontSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\FontSelector\Dropdown::validateSelectorUri()
  2. 8 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::validateSelectorUri()
Same name and namespace in other branches
  1. 8.3 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::validateSelectorUri()
  2. 8.2 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::validateSelectorUri()

Validation handler for the selection element.

File

src/Plugin/image_effects/ImageSelector/Dropdown.php, line 131

Class

Dropdown
Dropdown image selector plugin.

Namespace

Drupal\image_effects\Plugin\image_effects\ImageSelector

Code

public function validateSelectorUri($element, FormStateInterface $form_state, $form) {
  if (!empty($element['#value'])) {
    if (file_exists($file_path = $this->configuration['path'] . '/' . $element['#value'])) {
      $form_state
        ->setValueForElement($element, $file_path);
    }
    else {
      $form_state
        ->setErrorByName(implode('][', $element['#parents']), $this
        ->t('The selected file does not exist.'));
    }
  }
}