From 109049a6cc61c3eaed17565b4179670dbe71b2ac Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Sun, 6 Oct 2013 01:17:44 +0300 Subject: [PATCH] Issue #2105621 by claudiu.cristea: Inject config factory service into image toolkit manager. --- core/core.services.yml | 2 +- .../lib/Drupal/system/Plugin/ImageToolkitManager.php | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index 24ef51e..54dd634 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -526,7 +526,7 @@ services: - { name: event_subscriber } image.toolkit.manager: class: Drupal\system\Plugin\ImageToolkitManager - arguments: ['@container.namespaces', '@cache.cache', '@language_manager'] + arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@config.factory'] image.toolkit: class: Drupal\system\Plugin\ImageToolkitInterface factory_method: getDefaultToolkit diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php index 77e90c1..b29ab58 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php @@ -8,6 +8,7 @@ namespace Drupal\system\Plugin; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Plugin\DefaultPluginManager; @@ -17,6 +18,13 @@ class ImageToolkitManager extends DefaultPluginManager { /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** * Constructs the ImageToolkitManager object. * * @param \Traversable $namespaces @@ -26,10 +34,14 @@ class ImageToolkitManager extends DefaultPluginManager { * Cache backend instance to use. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory. */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager) { + public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ConfigFactory $config_factory) { parent::__construct('Plugin/ImageToolkit', $namespaces, 'Drupal\system\Annotation\ImageToolkit'); + $this->setCacheBackend($cache_backend, $language_manager, 'image_toolkit'); + $this->configFactory = $config_factory; } /** @@ -43,7 +55,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * Object of the default toolkit, or FALSE on error. */ public function getDefaultToolkit() { - $toolkit_id = \Drupal::config('system.image')->get('toolkit'); + $toolkit_id = $this->configFactory->get('system.image')->get('toolkit'); $toolkits = $this->getAvailableToolkits(); if (!isset($toolkits[$toolkit_id]) || !class_exists($toolkits[$toolkit_id]['class'])) { -- 1.8.3.1