diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitOperationManager.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitOperationManager.php index b03d814..bc49af1 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitOperationManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitOperationManager.php @@ -56,13 +56,15 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * A full image toolkit operation plugin ID (e.g. "system.gd.crop"). */ public function getToolkitOperationPluginId($toolkit, $operation) { - $definitions = $this->getDefinitions(); - uasort($definitions, '\Drupal\Component\Utility\SortArray::sortByWeightElement'); - $pattern = '|\\.' . $toolkit . '\\.' . $operation . '$|'; - foreach ($definitions as $plugin_id => $definition) { - if (preg_match($pattern, $plugin_id)) { - return $plugin_id; + $definitions = array_filter($this->getDefinitions(), function ($definition) use ($toolkit, $operation) { + return $definition['toolkit'] == $toolkit && $definition['operation'] == $operation; + }); + if ($definitions) { + if (count($definitions) > 1) { + uasort($definitions, '\Drupal\Component\Utility\SortArray::sortByWeightElement'); } + $definition = reset($definitions); + return $definition['id']; } } diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestCrop.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestCrop.php index eaa6643..db0445f 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestCrop.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestCrop.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\image_test\Plugin\ImageToolkitOperation\TestToolkitCrop. + * Contains \Drupal\image_test\Plugin\ImageToolkit\Operation\TestCrop. */ -namespace Drupal\image_test\Plugin\ImageToolkitOperation; +namespace Drupal\image_test\Plugin\ImageToolkit\Operation; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Annotation\Translation; @@ -18,15 +18,14 @@ * Defines Test Crop operation. * * @ImageToolkitOperation( - * id = "image_test_test_crop", + * operation = "crop", * label = @Translation("Crop"), * description = @Translation("Test toolkit crop"), * toolkit = "test", - * operation = "crop", * weight = 0 * ) */ -class TestToolkitCrop extends ImageToolkitOperationBase { +class TestCrop extends ImageToolkitOperationBase { /** * Crops an image. diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestDesaturate.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestDesaturate.php index a60a3e0..a48a28e 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestDesaturate.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestDesaturate.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\image_test\Plugin\ImageToolkitOperation\TestToolkitDesaturate. + * Contains \Drupal\image_test\Plugin\ImageToolkit\Operation\TestDesaturate. */ -namespace Drupal\image_test\Plugin\ImageToolkitOperation; +namespace Drupal\image_test\Plugin\ImageToolkit\Operation; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Annotation\Translation; @@ -18,15 +18,14 @@ * Defines Test Desaturate operation. * * @ImageToolkitOperation( - * id = "image_test_test_desaturate", + * operation = "desaturate", * label = @Translation("Desaturate"), * description = @Translation("Test toolkit desaturate"), * toolkit = "test", - * operation = "desaturate", * weight = 0 * ) */ -class TestToolkitDesaturate extends ImageToolkitOperationBase { +class TestDesaturate extends ImageToolkitOperationBase { /** * Converts an image resource to grayscale. diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestResize.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestResize.php index 9026534..8353fb6 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestResize.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestResize.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\image_test\Plugin\ImageToolkitOperation\TestToolkitResize. + * Contains \Drupal\image_test\Plugin\ImageToolkit\Operation\TestResize. */ -namespace Drupal\image_test\Plugin\ImageToolkitOperation; +namespace Drupal\image_test\Plugin\ImageToolkit\Operation; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Annotation\Translation; @@ -18,15 +18,14 @@ * Defines Test resize operation. * * @ImageToolkitOperation( - * id = "image_test_test_resize", + * operation = "resize", * label = @Translation("Resize"), * description = @Translation("Test toolkit resize"), * toolkit = "test", - * operation = "resize", * weight = 0 * ) */ -class TestToolkitResize extends ImageToolkitOperationBase { +class TestResize extends ImageToolkitOperationBase { /** * Scales an image to the specified size. diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestRotate.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestRotate.php index 7aaf0aa..b08476b 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestRotate.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/Operation/TestRotate.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\image_test\Plugin\ImageToolkitOperation\TestToolkitRotate. + * Contains \Drupal\image_test\Plugin\ImageToolkit\Operation\TestRotate. */ -namespace Drupal\image_test\Plugin\ImageToolkitOperation; +namespace Drupal\image_test\Plugin\ImageToolkit\Operation; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Annotation\Translation; @@ -18,15 +18,14 @@ * Defines Test rotate operation. * * @ImageToolkitOperation( - * id = "image_test_test_rotate", + * operation = "rotate", * label = @Translation("Rotate"), * description = @Translation("Test toolkit rotate"), * toolkit = "test", - * operation = "rotate", * weight = 0 * ) */ -class TestToolkitRotate extends ImageToolkitOperationBase { +class TestRotate extends ImageToolkitOperationBase { /** * Rotates an image the given number of degrees.