From a9e95605756f3956519a0660ee65b34061fb2bba Mon Sep 17 00:00:00 2001
From: Claudiu Cristea <clau.cristea@gmail.com>
Date: Tue, 8 Oct 2013 16:14:19 +0300
Subject: [PATCH] Issue #2048827 by tim.plunkett, claudiu.cristea: Move Image
 toolkit API from system.module to Drupal\Core.

---
 core/core.services.yml                                      |  4 ++--
 core/lib/Drupal/Core/Image/Image.php                        |  8 ++++----
 core/lib/Drupal/Core/Image/ImageFactory.php                 |  8 ++++----
 core/lib/Drupal/Core/Image/ImageInterface.php               | 10 +++++-----
 .../Drupal/Core/ImageToolkit}/ImageToolkitInterface.php     | 13 +++++++------
 .../Drupal/Core/ImageToolkit}/ImageToolkitManager.php       | 10 +++-------
 .../system/lib/Drupal/system/Annotation/ImageToolkit.php    |  4 ++--
 .../system/lib/Drupal/system/Form/ImageToolkitForm.php      |  4 ++--
 .../lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php     |  2 +-
 .../lib/Drupal/system/Tests/Image/ToolkitTestBase.php       |  2 +-
 .../Drupal/image_test/Plugin/ImageToolkit/BrokenToolkit.php |  2 +-
 .../Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php   |  2 +-
 core/tests/Drupal/Tests/Core/Image/ImageTest.php            |  2 +-
 13 files changed, 34 insertions(+), 37 deletions(-)
 rename core/{modules/system/lib/Drupal/system/Plugin => lib/Drupal/Core/ImageToolkit}/ImageToolkitInterface.php (94%)
 rename core/{modules/system/lib/Drupal/system/Plugin => lib/Drupal/Core/ImageToolkit}/ImageToolkitManager.php (90%)

diff --git a/core/core.services.yml b/core/core.services.yml
index 54dd634..8ace762 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -525,10 +525,10 @@ services:
     tags:
       - { name: event_subscriber }
   image.toolkit.manager:
-    class: Drupal\system\Plugin\ImageToolkitManager
+    class: Drupal\Core\ImageToolkit\ImageToolkitManager
     arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@config.factory']
   image.toolkit:
-    class: Drupal\system\Plugin\ImageToolkitInterface
+    class: Drupal\Core\ImageToolkit\ImageToolkitInterface
     factory_method: getDefaultToolkit
     factory_service: image.toolkit.manager
   image.factory:
diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php
index 0f2fc85..963ed5b 100644
--- a/core/lib/Drupal/Core/Image/Image.php
+++ b/core/lib/Drupal/Core/Image/Image.php
@@ -7,13 +7,13 @@
 
 namespace Drupal\Core\Image;
 
-use Drupal\system\Plugin\ImageToolkitInterface;
+use Drupal\Core\ImageToolkit\ImageToolkitInterface;
 use Drupal\Component\Utility\Image as ImageUtility;
 
 /**
  * Defines an image object to represent an image file.
  *
- * @see \Drupal\system\Plugin\ImageToolkitInterface
+ * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface
  * @see \Drupal\image\ImageEffectInterface
  *
  * @ingroup image
@@ -30,7 +30,7 @@ class Image implements ImageInterface {
   /**
    * An image toolkit object.
    *
-   * @var \Drupal\system\Plugin\ImageToolkitInterface
+   * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface
    */
   protected $toolkit;
 
@@ -95,7 +95,7 @@ class Image implements ImageInterface {
    *
    * @param string $source
    *   The path to an image file.
-   * @param \Drupal\system\Plugin\ImageToolkitInterface $toolkit
+   * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit
    *   The image toolkit.
    */
   public function __construct($source, ImageToolkitInterface $toolkit) {
diff --git a/core/lib/Drupal/Core/Image/ImageFactory.php b/core/lib/Drupal/Core/Image/ImageFactory.php
index 0ffc9a2..27773d8 100644
--- a/core/lib/Drupal/Core/Image/ImageFactory.php
+++ b/core/lib/Drupal/Core/Image/ImageFactory.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Core\Image;
 
-use Drupal\system\Plugin\ImageToolkitInterface;
+use Drupal\Core\ImageToolkit\ImageToolkitInterface;
 
 /**
  * Provides a factory for image objects.
@@ -17,14 +17,14 @@ class ImageFactory {
   /**
    * The image toolkit to use for this factory.
    *
-   * @var \Drupal\system\Plugin\ImageToolkitInterface
+   * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface
    */
   protected $toolkit;
 
   /**
    * Constructs a new ImageFactory object.
    *
-   * @param \Drupal\system\Plugin\ImageToolkitInterface $toolkit
+   * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit
    *   The image toolkit to use for this image factory.
    */
   public function __construct(ImageToolkitInterface $toolkit) {
@@ -34,7 +34,7 @@ public function __construct(ImageToolkitInterface $toolkit) {
   /**
    * Sets a custom image toolkit.
    *
-   * @param \Drupal\system\Plugin\ImageToolkitInterface $toolkit
+   * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit
    *   The image toolkit to use for this image factory.
    *
    * @return self
diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php
index 5966ab2..bba3460 100644
--- a/core/lib/Drupal/Core/Image/ImageInterface.php
+++ b/core/lib/Drupal/Core/Image/ImageInterface.php
@@ -153,7 +153,7 @@ public function getToolkitId();
    * @return bool
    *   TRUE on success, FALSE on failure.
    *
-   * @see \Drupal\system\Plugin\ImageToolkitInterface::save()
+   * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::save()
    */
   public function save($destination = NULL);
 
@@ -211,7 +211,7 @@ public function scaleAndCrop($width, $height);
    * @return bool
    *   TRUE on success, FALSE on failure.
    *
-   * @see \Drupal\system\Plugin\ImageToolkitInterface::crop()
+   * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::crop()
    */
   public function crop($x, $y, $width, $height);
 
@@ -226,7 +226,7 @@ public function crop($x, $y, $width, $height);
    * @return bool
    *   TRUE on success, FALSE on failure.
    *
-   * @see \Drupal\system\Plugin\ImageToolkitInterface::resize()
+   * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::resize()
    */
   public function resize($width, $height);
 
@@ -236,7 +236,7 @@ public function resize($width, $height);
    * @return bool
    *   TRUE on success, FALSE on failure.
    *
-   * @see \Drupal\system\Plugin\ImageToolkitInterface::desaturate()
+   * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::desaturate()
    */
   public function desaturate();
 
@@ -255,7 +255,7 @@ public function desaturate();
    * @return bool
    *   TRUE on success, FALSE on failure.
    *
-   * @see \Drupal\system\Plugin\ImageToolkitInterface::rotate()
+   * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface::rotate()
    */
   public function rotate($degrees, $background = NULL);
 
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
similarity index 94%
rename from core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php
rename to core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
index 5918160..2b86aef 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitInterface.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Contains \Drupal\system\Plugin\ImageToolkitInterface.
+ * Contains \Drupal\Core\ImageToolkit\ImageToolkitInterface.
  */
 
-namespace Drupal\system\Plugin;
+namespace Drupal\Core\ImageToolkit;
 
 use Drupal\Component\Plugin\PluginInspectionInterface;
 use Drupal\Core\Image\ImageInterface;
@@ -28,13 +28,13 @@
  * software.
  *
  * Image toolkits are discovered using the Plugin system using
- * \Drupal\system\Plugin\ImageToolkitManager. The toolkit must then be enabled
- * using the admin/config/media/image-toolkit form.
+ * \Drupal\Core\ImageToolkit\ImageToolkitManager. The toolkit must then be
+ * enabled using the admin/config/media/image-toolkit form.
  *
  * Only one toolkit may be selected at a time. If a module author wishes to call
  * a specific toolkit they can check that it is installed by calling
- * \Drupal\system\Plugin\ImageToolkitManager::getAvailableToolkits(), and then
- * calling its functions directly.
+ * \Drupal\Core\ImageToolkit\ImageToolkitManager::getAvailableToolkits(), and
+ * then calling its functions directly.
  */
 
 /**
@@ -189,4 +189,5 @@ public static function isAvailable();
    *   IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
    */
   public static function supportedTypes();
+
 }
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
similarity index 90%
rename from core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php
rename to core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
index b29ab58..9dd46d4 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php
+++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php
@@ -2,10 +2,10 @@
 
 /**
  * @file
- * Contains \Drupal\system\Plugin\ImageToolkitManager.
+ * Contains \Drupal\Core\ImageToolkit\ImageToolkitManager.
  */
 
-namespace Drupal\system\Plugin;
+namespace Drupal\Core\ImageToolkit;
 
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\ConfigFactory;
@@ -47,11 +47,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
   /**
    * Gets the default image toolkit.
    *
-   * @param string $toolkit_id
-   *   (optional) String specifying toolkit to load. NULL will load the default
-   *   toolkit.
-   *
-   * @return \Drupal\system\Plugin\ImageToolkitInterface
+   * @return \Drupal\Core\ImageToolkit\ImageToolkitInterface
    *   Object of the default toolkit, or FALSE on error.
    */
   public function getDefaultToolkit() {
diff --git a/core/modules/system/lib/Drupal/system/Annotation/ImageToolkit.php b/core/modules/system/lib/Drupal/system/Annotation/ImageToolkit.php
index 0fd89da..0a75e97 100644
--- a/core/modules/system/lib/Drupal/system/Annotation/ImageToolkit.php
+++ b/core/modules/system/lib/Drupal/system/Annotation/ImageToolkit.php
@@ -14,8 +14,8 @@
  *
  * @Annotation
  *
- * @see \Drupal\system\Plugin\ImageToolkitInterface
- * @see \Drupal\system\Plugin\ImageToolkitManager
+ * @see \Drupal\Core\ImageToolkit\ImageToolkitInterface
+ * @see \Drupal\Core\ImageToolkit\ImageToolkitManager
  */
 class ImageToolkit extends Plugin {
 
diff --git a/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php
index dcdb2cc..1ce6bd6 100644
--- a/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php
@@ -10,7 +10,7 @@
 use Drupal\Core\Config\ConfigFactory;
 use Drupal\Core\Config\Context\ContextInterface;
 use Drupal\Core\Form\ConfigFormBase;
-use Drupal\system\Plugin\ImageToolkitManager;
+use Drupal\Core\ImageToolkit\ImageToolkitManager;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -32,7 +32,7 @@ class ImageToolkitForm extends ConfigFormBase {
    *   The factory for configuration objects.
    * @param \Drupal\Core\Config\Context\ContextInterface $context
    *   The configuration context used for this configuration object.
-   * @param \Drupal\system\Plugin\ImageToolkitManager $manager
+   * @param \Drupal\Core\ImageToolkit\ImageToolkitManager $manager
    *   The image toolkit plugin manager.
    */
   public function __construct(ConfigFactory $config_factory, ContextInterface $context, ImageToolkitManager $manager) {
diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
index cf13884..fa8fe41 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php
@@ -11,7 +11,7 @@
 use Drupal\system\Annotation\ImageToolkit;
 use Drupal\Core\Annotation\Translation;
 use Drupal\Core\Image\ImageInterface;
-use Drupal\system\Plugin\ImageToolkitInterface;
+use Drupal\Core\ImageToolkit\ImageToolkitInterface;
 
 /**
  * Defines the GD2 toolkit for image manipulation within Drupal.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
index 38d7a91..74caee4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
@@ -24,7 +24,7 @@
   /**
    * The image toolkit.
    *
-   * @var \Drupal\system\Plugin\ImageToolkitInterface
+   * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface
    */
   protected $toolkit;
 
diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/BrokenToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/BrokenToolkit.php
index b7aeef5..ff63957 100644
--- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/BrokenToolkit.php
+++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/BrokenToolkit.php
@@ -21,7 +21,7 @@
 class BrokenToolkit extends TestToolkit {
 
   /**
-   * Implements \Drupal\system\Plugin\ImageToolkitInterface::isAvailable().
+   * {@inheritdoc}
    */
   public static function isAvailable() {
     return FALSE;
diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
index 778e9e2..726384d 100644
--- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
+++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
@@ -11,7 +11,7 @@
 use Drupal\system\Annotation\ImageToolkit;
 use Drupal\Core\Annotation\Translation;
 use Drupal\Core\Image\ImageInterface;
-use Drupal\system\Plugin\ImageToolkitInterface;
+use Drupal\Core\ImageToolkit\ImageToolkitInterface;
 
 /**
  * Defines a Test toolkit for image manipulation within Drupal.
diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
index 700973e..d2a5b61 100644
--- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php
+++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
@@ -25,7 +25,7 @@ class ImageTest extends UnitTestCase {
   /**
    * Image toolkit.
    *
-   * @var \Drupal\system\Plugin\ImageToolkitInterface
+   * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface
    */
   protected $toolkit;
 
-- 
1.8.3.1

