diff --git a/core/lib/Drupal/Core/ImageToolkit/Annotation/ImageToolkitOperation.php b/core/lib/Drupal/Core/ImageToolkit/Annotation/ImageToolkitOperation.php index 1e9b9d8..c41b5a9 100644 --- a/core/lib/Drupal/Core/ImageToolkit/Annotation/ImageToolkitOperation.php +++ b/core/lib/Drupal/Core/ImageToolkit/Annotation/ImageToolkitOperation.php @@ -27,9 +27,9 @@ class ImageToolkitOperation extends Plugin { * of the 'operation' definition keys. The 'toolkit' definition key is * derived from the class namespace, while the 'operation' key is annotated. * However, it is recommended that the following patterns be used: - * - '{toolkit}.{operation}' for the first implementation of an operation + * - '{toolkit}_{operation}' for the first implementation of an operation * by a toolkit. - * - '{module}.{toolkit}.{operation}' for overrides of existing + * - '{module}_{toolkit}_{operation}' for overrides of existing * implementations supplied by an alternative module, and for new * module-supplied operations. * @@ -38,6 +38,13 @@ class ImageToolkitOperation extends Plugin { public $id; /** + * The id of the image toolkit plugin for which the operation is implemented. + * + * @var string + */ + public $toolkit; + + /** * The machine name of the image toolkit operation implemented (e.g. "crop"). * * @var string diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php index 15c0487..350b9a5 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php @@ -39,18 +39,6 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac } /** - * {@inheritdoc} - */ - public function processDefinition(&$definition, $plugin_id) { - parent::processDefinition($definition, $plugin_id); - - // Get the toolkit ID from the image operation plugin class namespace. Each - // plugin is placed under Plugin\ImageToolkit\{plugin_id}. - $path = explode('\\', $definition['class']); - $definition['toolkit'] = $path[count($path) - 2]; - } - - /** * Returns the plugin ID for a given toolkit and operation. * * @param string $toolkit_id diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php index a9b494b..a01bd50 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Crop.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_crop", + * toolkit = "gd", * operation = "crop", * label = @Translation("Crop"), * description = @Translation("Crops an image to a rectangle specified by the given dimensions.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php index cd17f5f..069db6d 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_desaturate", + * toolkit = "gd", * operation = "desaturate", * label = @Translation("Desaturate"), * description = @Translation("Converts an image to grayscale.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php index 699e7bf..ba92ecd 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_resize", + * toolkit = "gd", * operation = "resize", * label = @Translation("Resize"), * description = @Translation("Resizes an image to the given dimensions (ignoring aspect ratio).") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php index f9b51d1..11abeac 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_rotate", + * toolkit = "gd", * operation = "rotate", * label = @Translation("Rotate"), * description = @Translation("Rotates an image by the given number of degrees.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php index 4d7f7f3..3d8b742 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_scale", + * toolkit = "gd", * operation = "scale", * label = @Translation("Scale"), * description = @Translation("Scales an image while maintaining aspect ratio. The resulting image can be smaller for one or both target dimensions.") diff --git a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php index 14df6b9..6b95e29 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php +++ b/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php @@ -14,6 +14,7 @@ * * @ImageToolkitOperation( * id = "gd_scale_and_crop", + * toolkit = "gd", * operation = "scale_and_crop", * label = @Translation("Scale and crop"), * description = @Translation("Scales an image to the exact width and height given. This plugin achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is useful to create uniform sized avatars from larger images.") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Crop.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Crop.php index 3928ff5..df88a82 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Crop.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Crop.php @@ -14,7 +14,8 @@ * Defines Test Crop operation. * * @ImageToolkitOperation( - * id = "test.crop", + * id = "test_crop", + * toolkit = "test", * operation = "crop", * label = @Translation("Crop"), * description = @Translation("Test toolkit crop") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Desaturate.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Desaturate.php index 1c87c5c..b40eaf6 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Desaturate.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Desaturate.php @@ -14,7 +14,8 @@ * Defines Test Desaturate operation. * * @ImageToolkitOperation( - * id = "test.desaturate", + * id = "test_desaturate", + * toolkit = "test", * operation = "desaturate", * label = @Translation("Desaturate"), * description = @Translation("Test toolkit desaturate") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Resize.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Resize.php index 6d2441e..df79fe2 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Resize.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Resize.php @@ -14,7 +14,8 @@ * Defines Test resize operation. * * @ImageToolkitOperation( - * id = "test.resize", + * id = "test_resize", + * toolkit = "test", * operation = "resize", * label = @Translation("Resize"), * description = @Translation("Test toolkit resize") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Rotate.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Rotate.php index 7d75121..3e91bd5 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Rotate.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Rotate.php @@ -14,7 +14,8 @@ * Defines Test rotate operation. * * @ImageToolkitOperation( - * id = "test.rotate", + * id = "test_rotate", + * toolkit = "test", * operation = "rotate", * label = @Translation("Rotate"), * description = @Translation("Test toolkit rotate") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Scale.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Scale.php index 198a4ea..cee8fe6 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Scale.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/Scale.php @@ -13,7 +13,8 @@ * Defines Test Scale operation. * * @ImageToolkitOperation( - * id = "test.scale", + * id = "test_scale", + * toolkit = "test", * operation = "scale", * label = @Translation("Scale"), * description = @Translation("Scales an image while maintaining aspect ratio. The resulting image can be smaller for one or both target dimensions.") diff --git a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ScaleAndCrop.php b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ScaleAndCrop.php index f857e69..0469b08 100644 --- a/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ScaleAndCrop.php +++ b/core/modules/system/tests/modules/image_test/src/Plugin/ImageToolkit/Operation/test/ScaleAndCrop.php @@ -13,7 +13,8 @@ * Defines Test Scale and Crop operation. * * @ImageToolkitOperation( - * id = "test.scale_and_crop", + * id = "test_scale_and_crop", + * toolkit = "test", * operation = "scale_and_crop", * label = @Translation("Scale and crop"), * description = @Translation("Scales an image to the exact width and height given. This plugin achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is useful to create uniform sized avatars from larger images.")