Skip to content
Snippets Groups Projects
Commit 746540d1 authored by catch's avatar catch
Browse files

Issue #3421480 by Spokje, longwave, andypost: Convert OpenerResolver to use a service locator

(cherry picked from commit dafa2ad8)
parent b7348d1b
No related branches found
No related tags found
26 merge requests!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
Pipeline #111517 passed with warnings
......@@ -9,8 +9,8 @@ services:
class: Drupal\media_library\Routing\RouteSubscriber
media_library.opener_resolver:
class: Drupal\media_library\OpenerResolver
calls:
- [setContainer, ['@service_container']]
tags:
- { name: service_collector, tag: media_library.opener, call: addOpener }
Drupal\media_library\OpenerResolverInterface: '@media_library.opener_resolver'
media_library.opener.field_widget:
class: Drupal\media_library\MediaLibraryFieldWidgetOpener
......
<?php
declare(strict_types=1);
namespace Drupal\media_library;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
/**
* Service provider for media library services.
*/
class MediaLibraryServiceProvider implements ServiceProviderInterface {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
$container->registerForAutoconfiguration(MediaLibraryOpenerInterface::class)
->addTag('media_library.opener');
}
}
......@@ -2,10 +2,8 @@
namespace Drupal\media_library;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
/**
* Defines a class to get media library openers from the container.
* Defines a class to resolve media library openers.
*
* This is intended to be a very thin interface-verifying wrapper around
* services which implement \Drupal\media_library\MediaLibraryOpenerInterface.
......@@ -18,7 +16,22 @@
*/
class OpenerResolver implements OpenerResolverInterface {
use ContainerAwareTrait;
/**
* @var \Drupal\media_library\MediaLibraryOpenerInterface[]
*/
protected array $openers = [];
/**
* Registers an opener.
*
* @param \Drupal\media_library\MediaLibraryOpenerInterface $opener
* The opener.
* @param string $id
* The service ID.
*/
public function addOpener(MediaLibraryOpenerInterface $opener, string $id): void {
$this->openers[$id] = $opener;
}
/**
* {@inheritdoc}
......@@ -26,7 +39,7 @@ class OpenerResolver implements OpenerResolverInterface {
public function get(MediaLibraryState $state) {
$service_id = $state->getOpenerId();
$service = $this->container->get($service_id);
$service = $this->openers[$service_id] ?? NULL;
if ($service instanceof MediaLibraryOpenerInterface) {
return $service;
}
......
......@@ -29,6 +29,7 @@ class MediaLibraryAddFormTest extends KernelTestBase {
'media_library',
'file',
'field',
'filter',
'image',
'system',
'views',
......
......@@ -29,6 +29,7 @@ class MediaLibraryWidgetTest extends KernelTestBase {
'media',
'media_library',
'field',
'filter',
'image',
'system',
'views',
......
......@@ -1386,14 +1386,6 @@ parameters:
count: 1
path: modules/media/src/OEmbed/UrlResolver.php
-
message: """
#^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\media_library\\\\OpenerResolver\\:
since Symfony 6\\.4, use dependency injection instead$#
"""
count: 1
path: modules/media_library/src/OpenerResolver.php
-
message: "#^Variable \\$jpg_image might not be defined\\.$#"
count: 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment