Skip to content
Snippets Groups Projects
Verified Commit 6d67339d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3420996 by mstrelan, kim.pepper, larowlan: Convert ImageEffect plugin...

Issue #3420996 by mstrelan, kim.pepper, larowlan: Convert ImageEffect plugin discovery to attributes

(cherry picked from commit 58ecf6d4)
parent 129230f1
No related branches found
No related tags found
28 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7627Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country support from DateFormatter,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!7401#3271894 Fix documented StreamWrapperInterface return types for realpath() and dirname(),!7384Add constraints to system.advisories,!7078Issue #3320569 by Spokje, mondrake, smustgrave, longwave, quietone, Lendude,...,!6622Issue #2559833 by piggito, mohit_aghera, larowlan, guptahemant, vakulrai,...,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #106384 passed with warnings
Pipeline: drupal

#106404

    Pipeline: drupal

    #106397

      Pipeline: drupal

      #106387

        Showing
        with 119 additions and 58 deletions
        <?php
        declare(strict_types=1);
        namespace Drupal\image\Attribute;
        use Drupal\Component\Plugin\Attribute\Plugin;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        /**
        * Defines an ImageEffect attribute for plugin discovery.
        *
        * Plugin Namespace: Plugin\ImageEffect
        *
        * For a working example, see
        * \Drupal\image\Plugin\ImageEffect\ResizeImageEffect
        *
        * @see hook_image_effect_info_alter()
        * @see \Drupal\image\ConfigurableImageEffectInterface
        * @see \Drupal\image\ConfigurableImageEffectBase
        * @see \Drupal\image\ImageEffectInterface
        * @see \Drupal\image\ImageEffectBase
        * @see \Drupal\image\ImageEffectManager
        * @see \Drupal\Core\ImageToolkit\Annotation\ImageToolkitOperation
        * @see plugin_api
        */
        #[\Attribute(\Attribute::TARGET_CLASS)]
        class ImageEffect extends Plugin {
        /**
        * Constructs an ImageEffect attribute.
        *
        * @param string $id
        * The plugin ID.
        * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
        * The human-readable name of the image effect.
        * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
        * (optional) A brief description of the image effect. This will be shown
        * when adding or configuring this image effect.
        * @param class-string|null $deriver
        * (optional) The deriver class.
        */
        public function __construct(
        public readonly string $id,
        public readonly TranslatableMarkup $label,
        public readonly ?TranslatableMarkup $description = NULL,
        public readonly ?string $deriver = NULL,
        ) {}
        }
        ......@@ -5,6 +5,7 @@
        use Drupal\Core\Cache\CacheBackendInterface;
        use Drupal\Core\Extension\ModuleHandlerInterface;
        use Drupal\Core\Plugin\DefaultPluginManager;
        use Drupal\image\Attribute\ImageEffect;
        /**
        * Manages image effect plugins.
        ......@@ -31,7 +32,7 @@ class ImageEffectManager extends DefaultPluginManager {
        * The module handler.
        */
        public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
        parent::__construct('Plugin/ImageEffect', $namespaces, $module_handler, 'Drupal\image\ImageEffectInterface', 'Drupal\image\Annotation\ImageEffect');
        parent::__construct('Plugin/ImageEffect', $namespaces, $module_handler, 'Drupal\image\ImageEffectInterface', ImageEffect::class, 'Drupal\image\Annotation\ImageEffect');
        $this->alterInfo('image_effect_info');
        $this->setCacheBackend($cache_backend, 'image_effect_plugins');
        ......
        ......@@ -4,17 +4,18 @@
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ConfigurableImageEffectBase;
        /**
        * Converts an image resource.
        *
        * @ImageEffect(
        * id = "image_convert",
        * label = @Translation("Convert"),
        * description = @Translation("Converts an image to a format (such as JPEG).")
        * )
        */
        #[ImageEffect(
        id: "image_convert",
        label: new TranslatableMarkup("Convert"),
        description: new TranslatableMarkup("Converts an image to a format (such as JPEG)."),
        )]
        class ConvertImageEffect extends ConfigurableImageEffectBase {
        /**
        ......
        ......@@ -4,16 +4,17 @@
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        /**
        * Crops an image resource.
        *
        * @ImageEffect(
        * id = "image_crop",
        * label = @Translation("Crop"),
        * description = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.")
        * )
        */
        #[ImageEffect(
        id: "image_crop",
        label: new TranslatableMarkup("Crop"),
        description: new TranslatableMarkup("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately."),
        )]
        class CropImageEffect extends ResizeImageEffect {
        /**
        ......
        ......@@ -3,17 +3,18 @@
        namespace Drupal\image\Plugin\ImageEffect;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ImageEffectBase;
        /**
        * Desaturates (grayscale) an image resource.
        *
        * @ImageEffect(
        * id = "image_desaturate",
        * label = @Translation("Desaturate"),
        * description = @Translation("Desaturate converts an image to grayscale.")
        * )
        */
        #[ImageEffect(
        id: "image_desaturate",
        label: new TranslatableMarkup("Desaturate"),
        description: new TranslatableMarkup("Desaturate converts an image to grayscale."),
        )]
        class DesaturateImageEffect extends ImageEffectBase {
        /**
        ......
        ......@@ -4,17 +4,18 @@
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ConfigurableImageEffectBase;
        /**
        * Resizes an image resource.
        *
        * @ImageEffect(
        * id = "image_resize",
        * label = @Translation("Resize"),
        * description = @Translation("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately.")
        * )
        */
        #[ImageEffect(
        id: "image_resize",
        label: new TranslatableMarkup("Resize"),
        description: new TranslatableMarkup("Resizing will make images an exact set of dimensions. This may cause images to be stretched or shrunk disproportionately."),
        )]
        class ResizeImageEffect extends ConfigurableImageEffectBase {
        /**
        ......
        ......@@ -6,17 +6,18 @@
        use Drupal\Component\Utility\Rectangle;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ConfigurableImageEffectBase;
        /**
        * Rotates an image resource.
        *
        * @ImageEffect(
        * id = "image_rotate",
        * label = @Translation("Rotate"),
        * description = @Translation("Rotating an image may cause the dimensions of an image to increase to fit the diagonal.")
        * )
        */
        #[ImageEffect(
        id: "image_rotate",
        label: new TranslatableMarkup("Rotate"),
        description: new TranslatableMarkup("Rotating an image may cause the dimensions of an image to increase to fit the diagonal.")
        )]
        class RotateImageEffect extends ConfigurableImageEffectBase {
        /**
        ......
        ......@@ -3,16 +3,17 @@
        namespace Drupal\image\Plugin\ImageEffect;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        /**
        * Scales and crops an image resource.
        *
        * @ImageEffect(
        * id = "image_scale_and_crop",
        * label = @Translation("Scale and crop"),
        * description = @Translation("Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.")
        * )
        */
        #[ImageEffect(
        id: "image_scale_and_crop",
        label: new TranslatableMarkup("Scale and crop"),
        description: new TranslatableMarkup("Scale and crop will maintain the aspect-ratio of the original image, then crop the larger dimension. This is most useful for creating perfectly square thumbnails without stretching the image.")
        )]
        class ScaleAndCropImageEffect extends CropImageEffect {
        /**
        ......
        ......@@ -5,16 +5,17 @@
        use Drupal\Component\Utility\Image;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        /**
        * Scales an image resource.
        *
        * @ImageEffect(
        * id = "image_scale",
        * label = @Translation("Scale"),
        * description = @Translation("Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.")
        * )
        */
        #[ImageEffect(
        id: "image_scale",
        label: new TranslatableMarkup("Scale"),
        description: new TranslatableMarkup("Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.")
        )]
        class ScaleImageEffect extends ResizeImageEffect {
        /**
        ......
        ......@@ -6,16 +6,17 @@
        use Drupal\Core\Ajax\HtmlCommand;
        use Drupal\Core\Form\FormStateInterface;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ConfigurableImageEffectBase;
        /**
        * Provides a test effect using Ajax in the configuration form.
        *
        * @ImageEffect(
        * id = "image_module_test_ajax",
        * label = @Translation("Ajax test")
        * )
        */
        #[ImageEffect(
        id: "image_module_test_ajax",
        label: new TranslatableMarkup("Ajax test")
        )]
        class AjaxTestImageEffect extends ConfigurableImageEffectBase {
        /**
        ......
        ......@@ -3,16 +3,17 @@
        namespace Drupal\image_module_test\Plugin\ImageEffect;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ImageEffectBase;
        /**
        * Performs no operation on an image resource.
        *
        * @ImageEffect(
        * id = "image_module_test_null",
        * label = @Translation("Image module test")
        * )
        */
        #[ImageEffect(
        id: "image_module_test_null",
        label: new TranslatableMarkup("Image module test")
        )]
        class NullTestImageEffect extends ImageEffectBase {
        /**
        ......
        ......@@ -3,16 +3,17 @@
        namespace Drupal\image_module_test\Plugin\ImageEffect;
        use Drupal\Core\Image\ImageInterface;
        use Drupal\Core\StringTranslation\TranslatableMarkup;
        use Drupal\image\Attribute\ImageEffect;
        use Drupal\image\ImageEffectBase;
        /**
        * Performs an image operation that depends on the URI of the original image.
        *
        * @ImageEffect(
        * id = "image_module_test_uri_dependent",
        * label = @Translation("URI dependent test image effect")
        * )
        */
        #[ImageEffect(
        id: "image_module_test_uri_dependent",
        label: new TranslatableMarkup("URI dependent test image effect")
        )]
        class UriDependentTestImageEffect extends ImageEffectBase {
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment