Skip to content
Snippets Groups Projects
Verified Commit e8b4e5c2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3420991 by kim.pepper, larowlan, mstrelan: Convert ImageToolkit plugin...

Issue #3420991 by kim.pepper, larowlan, mstrelan: Convert ImageToolkit plugin discovery to attributes

(cherry picked from commit ffaf9871)
parent 4eed1aa1
Branches
Tags
28 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7627Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country support from DateFormatter,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!7401#3271894 Fix documented StreamWrapperInterface return types for realpath() and dirname(),!7384Add constraints to system.advisories,!7078Issue #3320569 by Spokje, mondrake, smustgrave, longwave, quietone, Lendude,...,!6622Issue #2559833 by piggito, mohit_aghera, larowlan, guptahemant, vakulrai,...,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
<?php
declare(strict_types=1);
namespace Drupal\Core\ImageToolkit\Attribute;
use Drupal\Component\Plugin\Attribute\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Defines a Plugin attribute for the image toolkit plugin.
*
* An image toolkit provides common image file manipulations like scaling,
* cropping, and rotating.
*
* Plugin namespace: Plugin\ImageToolkit
*
* For a working example, see
* \Drupal\system\Plugin\ImageToolkit\GDToolkit
*
* @see \Drupal\Core\ImageToolkit\Annotation\ImageToolkitOperation
* @see \Drupal\Core\ImageToolkit\ImageToolkitInterface
* @see \Drupal\Core\ImageToolkit\ImageToolkitBase
* @see \Drupal\Core\ImageToolkit\ImageToolkitManager
* @see plugin_api
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class ImageToolkit extends Plugin {
public function __construct(
public readonly string $id,
public readonly TranslatableMarkup $title,
public readonly ?string $deriver = NULL,
) {}
}
......@@ -5,6 +5,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkit;
use Drupal\Core\Plugin\DefaultPluginManager;
/**
......@@ -38,7 +39,14 @@ class ImageToolkitManager extends DefaultPluginManager {
* The config factory.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) {
parent::__construct('Plugin/ImageToolkit', $namespaces, $module_handler, 'Drupal\Core\ImageToolkit\ImageToolkitInterface', 'Drupal\Core\ImageToolkit\Annotation\ImageToolkit');
parent::__construct(
'Plugin/ImageToolkit',
$namespaces,
$module_handler,
ImageToolkitInterface::class,
ImageToolkit::class,
'Drupal\Core\ImageToolkit\Annotation\ImageToolkit',
);
$this->setCacheBackend($cache_backend, 'image_toolkit_plugins');
$this->configFactory = $config_factory;
......
......@@ -7,11 +7,13 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkit;
use Drupal\Core\ImageToolkit\ImageToolkitBase;
use Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -19,12 +21,11 @@
/**
* Defines the GD2 toolkit for image manipulation within Drupal.
*
* @ImageToolkit(
* id = "gd",
* title = @Translation("GD2 image manipulation toolkit")
* )
*/
#[ImageToolkit(
id: "gd",
title: new TranslatableMarkup("GD2 image manipulation toolkit"),
)]
class GDToolkit extends ImageToolkitBase {
/**
......
......@@ -2,14 +2,16 @@
namespace Drupal\image_test\Plugin\ImageToolkit;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkit;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Defines a Test toolkit for image manipulation within Drupal.
*
* @ImageToolkit(
* id = "broken",
* title = @Translation("A dummy toolkit that is broken")
* )
*/
#[ImageToolkit(
id: "broken",
title: new TranslatableMarkup("A dummy toolkit that is broken"),
)]
class BrokenToolkit extends TestToolkit {
/**
......
......@@ -2,12 +2,14 @@
namespace Drupal\image_test\Plugin\ImageToolkit;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkit;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Provides a derivative of TestToolkit.
*
* @ImageToolkit(
* id = "test:derived_toolkit",
* title = @Translation("A dummy toolkit, derivative of 'test'.")
* )
*/
#[ImageToolkit(
id: "test:derived_toolkit",
title: new TranslatableMarkup("A dummy toolkit, derivative of 'test'."),
)]
class DerivedToolkit extends TestToolkit {}
......@@ -4,20 +4,21 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkit;
use Drupal\Core\ImageToolkit\ImageToolkitBase;
use Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a Test toolkit for image manipulation within Drupal.
*
* @ImageToolkit(
* id = "test",
* title = @Translation("A dummy toolkit that works")
* )
*/
#[ImageToolkit(
id: "test",
title: new TranslatableMarkup("A dummy toolkit that works"),
)]
class TestToolkit extends ImageToolkitBase {
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment