You are here

trait MirrorTrait in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/MirrorTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\MirrorTrait
  2. 8 src/Plugin/ImageToolkit/Operation/MirrorTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\MirrorTrait

Base trait for image_effects Mirror operations.

Hierarchy

  • trait \Drupal\image_effects\Plugin\ImageToolkit\Operation\MirrorTrait
2 files declare their use of MirrorTrait
Mirror.php in src/Plugin/ImageToolkit/Operation/gd/Mirror.php
Mirror.php in src/Plugin/ImageToolkit/Operation/imagemagick/Mirror.php

File

src/Plugin/ImageToolkit/Operation/MirrorTrait.php, line 8

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation
View source
trait MirrorTrait {

  /**
   * {@inheritdoc}
   */
  protected function arguments() {
    return [
      'x_axis' => [
        'description' => 'Flop the source image horizontally.',
        'required' => FALSE,
        'default' => FALSE,
      ],
      'y_axis' => [
        'description' => 'Flip the source image vertically.',
        'required' => FALSE,
        'default' => FALSE,
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function validateArguments(array $arguments) {

    // Ensure either horizontal flop or vertical flip is requested.
    $arguments['x_axis'] = (bool) $arguments['x_axis'];
    $arguments['y_axis'] = (bool) $arguments['y_axis'];
    if ($arguments['x_axis'] === FALSE && $arguments['y_axis'] === FALSE) {
      throw new \InvalidArgumentException("Neither horizontal flop nor vertical flip is specified for the image 'mirror' operation");
    }
    return $arguments;
  }

}

Members