예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function validateArguments(array $arguments)
 {
     // Assure color is a valid hex string.
     if (!Color::validateHex($arguments['RGB'])) {
         throw new \InvalidArgumentException("Invalid color ('{$arguments['RGB']}') specified for the image 'colorshift' operation");
     }
     return $arguments;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function validateArguments(array $arguments)
 {
     // Assure extension is supported.
     if (!in_array($arguments['extension'], $this->getToolkit()->getSupportedExtensions())) {
         throw new \InvalidArgumentException("Invalid extension ('{$arguments['extension']}') specified for the image 'convert' operation");
     }
     // Assure integers for width and height.
     $arguments['width'] = (int) round($arguments['width']);
     $arguments['height'] = (int) round($arguments['height']);
     // Fail when width or height are 0 or negative.
     if ($arguments['width'] <= 0) {
         throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'create_new' operation");
     }
     if ($arguments['height'] <= 0) {
         throw new \InvalidArgumentException("Invalid height ({$arguments['height']}) specified for the image 'create_new' operation");
     }
     // Assure transparent color is a valid hex string.
     if ($arguments['transparent_color'] && !Color::validateHex($arguments['transparent_color'])) {
         throw new \InvalidArgumentException("Invalid transparent color ({$arguments['transparent_color']}) specified for the image 'create_new' operation");
     }
     return $arguments;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     if (!$form_state->isValueEmpty('bgcolor') && !Color::validateHex($form_state->getValue('bgcolor'))) {
         $form_state->setErrorByName('bgcolor', $this->t('Background color must be a hexadecimal color value.'));
     }
 }