Loading core/core.services.yml +2 −2 Original line number Diff line number Diff line Loading @@ -1568,14 +1568,14 @@ services: - { name: stream_wrapper, scheme: theme } image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager arguments: ['@config.factory'] autowire: true parent: default_plugin_manager tags: - { name: plugin_manager_cache_clear } Drupal\Core\ImageToolkit\ImageToolkitManager: '@image.toolkit.manager' image.toolkit.operation.manager: class: Drupal\Core\ImageToolkit\ImageToolkitOperationManager arguments: ['@logger.channel.image', '@image.toolkit.manager'] autowire: true parent: default_plugin_manager tags: - { name: plugin_manager_cache_clear } Loading core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +12 −28 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Psr\Log\LoggerInterface; Loading @@ -16,14 +17,7 @@ * @see \Drupal\Core\ImageToolkit\ImageToolkitManager * @see plugin_api */ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterface { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterface, ContainerFactoryPluginInterface { /** * Path of the image file. Loading @@ -32,20 +26,6 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf */ protected $source = ''; /** * The image toolkit operation manager. * * @var \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface */ protected $operationManager; /** * A logger instance. * * @var \Psr\Log\LoggerInterface */ protected $logger; /** * Constructs an ImageToolkitBase object. * Loading @@ -55,18 +35,22 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf * The plugin ID for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager * @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operationManager * The toolkit operation manager. * @param \Psr\Log\LoggerInterface $logger * A logger instance. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory) { public function __construct( array $configuration, string $plugin_id, array $plugin_definition, protected readonly ImageToolkitOperationManagerInterface $operationManager, protected readonly LoggerInterface $logger, protected readonly ConfigFactoryInterface $configFactory, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->operationManager = $operation_manager; $this->logger = $logger; $this->configFactory = $config_factory; } /** Loading core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php +6 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,12 @@ class ImageToolkitManager extends DefaultPluginManager { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { public function __construct( \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, ) { parent::__construct( 'Plugin/ImageToolkit', $namespaces, Loading core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +31 −12 Original line number Diff line number Diff line Loading @@ -3,8 +3,10 @@ namespace Drupal\Core\ImageToolkit; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; /** * Provides a base class for image toolkit operation plugins. Loading @@ -14,21 +16,17 @@ * @see \Drupal\Core\ImageToolkit\ImageToolkitOperationManager * @see plugin_api */ abstract class ImageToolkitOperationBase extends PluginBase implements ImageToolkitOperationInterface { abstract class ImageToolkitOperationBase extends PluginBase implements ImageToolkitOperationInterface, ContainerFactoryPluginInterface { /** * The image toolkit. * * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface */ protected $toolkit; protected ImageToolkitInterface $toolkit; /** * A logger instance. * * @var \Psr\Log\LoggerInterface */ protected $logger; protected readonly LoggerInterface $logger; /** * Constructs an image toolkit operation plugin. Loading @@ -39,16 +37,37 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool * The plugin ID for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * The image toolkit. * @param \Psr\Log\LoggerInterface $logger * @param \Psr\Log\LoggerInterface|\Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * (deprecated) The image toolkit. * @param \Psr\Log\LoggerInterface|null $logger * A logger instance. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitInterface $toolkit, LoggerInterface $logger) { public function __construct( array $configuration, string $plugin_id, array $plugin_definition, #[Autowire(service: 'logger.channel.image')] LoggerInterface|ImageToolkitInterface $toolkit, #[Autowire(service: 'logger.channel.image')] ?LoggerInterface $logger = NULL, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); if ($toolkit instanceof ImageToolkitInterface) { @trigger_error('The $toolkit argument of ' . __METHOD__ . ' is deprecated in drupal:11.4.0 and the argument is removed from drupal:13.0.0. Use ::setToolkit() instead. See https://www.drupal.org/node/3562304', E_USER_DEPRECATED); $this->toolkit = $toolkit; $this->logger = $logger; } else { $this->logger = $toolkit; } } /** * {@inheritdoc} */ public function setToolkit(ImageToolkitInterface $toolkit): void { $this->toolkit = $toolkit; } /** * Returns the image toolkit instance for this operation. Loading core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationInterface.php +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,14 @@ */ interface ImageToolkitOperationInterface extends PluginInspectionInterface { /** * Set the image toolkit instance for this operation. * * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * The image toolkit in use. */ public function setToolkit(ImageToolkitInterface $toolkit): void; /** * Applies a toolkit specific operation to an image. * Loading Loading
core/core.services.yml +2 −2 Original line number Diff line number Diff line Loading @@ -1568,14 +1568,14 @@ services: - { name: stream_wrapper, scheme: theme } image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager arguments: ['@config.factory'] autowire: true parent: default_plugin_manager tags: - { name: plugin_manager_cache_clear } Drupal\Core\ImageToolkit\ImageToolkitManager: '@image.toolkit.manager' image.toolkit.operation.manager: class: Drupal\Core\ImageToolkit\ImageToolkitOperationManager arguments: ['@logger.channel.image', '@image.toolkit.manager'] autowire: true parent: default_plugin_manager tags: - { name: plugin_manager_cache_clear } Loading
core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +12 −28 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Psr\Log\LoggerInterface; Loading @@ -16,14 +17,7 @@ * @see \Drupal\Core\ImageToolkit\ImageToolkitManager * @see plugin_api */ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterface { /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterface, ContainerFactoryPluginInterface { /** * Path of the image file. Loading @@ -32,20 +26,6 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf */ protected $source = ''; /** * The image toolkit operation manager. * * @var \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface */ protected $operationManager; /** * A logger instance. * * @var \Psr\Log\LoggerInterface */ protected $logger; /** * Constructs an ImageToolkitBase object. * Loading @@ -55,18 +35,22 @@ abstract class ImageToolkitBase extends PluginBase implements ImageToolkitInterf * The plugin ID for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager * @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operationManager * The toolkit operation manager. * @param \Psr\Log\LoggerInterface $logger * A logger instance. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The config factory. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitOperationManagerInterface $operation_manager, LoggerInterface $logger, ConfigFactoryInterface $config_factory) { public function __construct( array $configuration, string $plugin_id, array $plugin_definition, protected readonly ImageToolkitOperationManagerInterface $operationManager, protected readonly LoggerInterface $logger, protected readonly ConfigFactoryInterface $configFactory, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->operationManager = $operation_manager; $this->logger = $logger; $this->configFactory = $config_factory; } /** Loading
core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php +6 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,12 @@ class ImageToolkitManager extends DefaultPluginManager { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { public function __construct( \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, ) { parent::__construct( 'Plugin/ImageToolkit', $namespaces, Loading
core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +31 −12 Original line number Diff line number Diff line Loading @@ -3,8 +3,10 @@ namespace Drupal\Core\ImageToolkit; use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; /** * Provides a base class for image toolkit operation plugins. Loading @@ -14,21 +16,17 @@ * @see \Drupal\Core\ImageToolkit\ImageToolkitOperationManager * @see plugin_api */ abstract class ImageToolkitOperationBase extends PluginBase implements ImageToolkitOperationInterface { abstract class ImageToolkitOperationBase extends PluginBase implements ImageToolkitOperationInterface, ContainerFactoryPluginInterface { /** * The image toolkit. * * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface */ protected $toolkit; protected ImageToolkitInterface $toolkit; /** * A logger instance. * * @var \Psr\Log\LoggerInterface */ protected $logger; protected readonly LoggerInterface $logger; /** * Constructs an image toolkit operation plugin. Loading @@ -39,16 +37,37 @@ abstract class ImageToolkitOperationBase extends PluginBase implements ImageTool * The plugin ID for the plugin instance. * @param array $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * The image toolkit. * @param \Psr\Log\LoggerInterface $logger * @param \Psr\Log\LoggerInterface|\Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * (deprecated) The image toolkit. * @param \Psr\Log\LoggerInterface|null $logger * A logger instance. */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, ImageToolkitInterface $toolkit, LoggerInterface $logger) { public function __construct( array $configuration, string $plugin_id, array $plugin_definition, #[Autowire(service: 'logger.channel.image')] LoggerInterface|ImageToolkitInterface $toolkit, #[Autowire(service: 'logger.channel.image')] ?LoggerInterface $logger = NULL, ) { parent::__construct($configuration, $plugin_id, $plugin_definition); if ($toolkit instanceof ImageToolkitInterface) { @trigger_error('The $toolkit argument of ' . __METHOD__ . ' is deprecated in drupal:11.4.0 and the argument is removed from drupal:13.0.0. Use ::setToolkit() instead. See https://www.drupal.org/node/3562304', E_USER_DEPRECATED); $this->toolkit = $toolkit; $this->logger = $logger; } else { $this->logger = $toolkit; } } /** * {@inheritdoc} */ public function setToolkit(ImageToolkitInterface $toolkit): void { $this->toolkit = $toolkit; } /** * Returns the image toolkit instance for this operation. Loading
core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationInterface.php +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,14 @@ */ interface ImageToolkitOperationInterface extends PluginInspectionInterface { /** * Set the image toolkit instance for this operation. * * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit * The image toolkit in use. */ public function setToolkit(ImageToolkitInterface $toolkit): void; /** * Applies a toolkit specific operation to an image. * Loading