Skip to content
Snippets Groups Projects
Verified Commit 58ecf6d4 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
parent 1366a3ae
No related branches found
No related tags found
30 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #106390 canceled
Pipeline: drupal

#106392

    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.
    Finish editing this message first!
    Please register or to comment