Skip to content
Snippets Groups Projects
Commit dd6a99e0 authored by Oleksandr Milkovskyi's avatar Oleksandr Milkovskyi
Browse files

Issue #3289392 by steffenr, project update bot, stborchert, osopolar:...

Issue #3289392 by steffenr, project update bot, stborchert, osopolar: Automated Drupal 10 compatibility fixes
parent bb952ba7
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ name: 'Media Riddle Marketplace'
description: 'Integrates riddle module with media'
package: Riddle
type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^10
dependencies:
- drupal:media
- riddle_marketplace:riddle_marketplace
......@@ -13,7 +13,7 @@ use Drupal\Core\File\FileSystemInterface;
function media_riddle_marketplace_install() {
/** @var \Drupal\Core\File\FileSystemInterface $filesystem */
$filesystem = \Drupal::service('file_system');
$source = drupal_get_path('module', 'media_riddle_marketplace') . '/images';
$source = \Drupal::service('extension.list.module')->getPath('media_riddle_marketplace') . '/images';
$destination = \Drupal::config('media.settings')->get('icon_base_uri');
$filesystem->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
......
......@@ -14,7 +14,7 @@ use Drupal\riddle_marketplace\RiddleFeedServiceInterface;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
/**
* Provides media type plugin for Riddle.
......@@ -57,6 +57,13 @@ class Riddle extends MediaSourceBase {
*/
protected $riddleFeed;
/**
* The mime type guesser.
*
* @var \Symfony\Component\Mime\MimeTypeGuesserInterface
*/
protected $mimeTypeGuesser;
/**
* Constructs a new class instance.
*
......@@ -80,12 +87,15 @@ class Riddle extends MediaSourceBase {
* The http client service.
* @param \Drupal\riddle_marketplace\RiddleFeedServiceInterface $riddleFeed
* Riddle feed service.
* @param \Symfony\Component\Mime\MimeTypeGuesserInterface $mimeTypeGuesser
* The mime type guesser.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, FileSystem $file_system, Client $http_client, RiddleFeedServiceInterface $riddleFeed) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, FileSystem $file_system, Client $http_client, RiddleFeedServiceInterface $riddleFeed, MimeTypeGuesserInterface $mimeTypeGuesser) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $config_factory);
$this->fileSystem = $file_system;
$this->httpClient = $http_client;
$this->riddleFeed = $riddleFeed;
$this->mimeTypeGuesser = $mimeTypeGuesser;
}
/**
......@@ -102,7 +112,8 @@ class Riddle extends MediaSourceBase {
$container->get('config.factory'),
$container->get('file_system'),
$container->get('http_client'),
$container->get('riddle_marketplace.feed')
$container->get('riddle_marketplace.feed'),
$container->get('file.mime_type.guesser')
);
}
......@@ -214,12 +225,10 @@ class Riddle extends MediaSourceBase {
* @return string|null
* The guessed extension or null if it cannot be guessed.
*
* @see ExtensionGuesser
* @see getMimeType()
*/
public function guessExtension($mime_type) {
$guesser = ExtensionGuesser::getInstance();
return $guesser->guess($mime_type);
public function guessExtension($mime_type): ?string {
return $this->mimeTypeGuesser->guessMimeType($mime_type);
}
}
......@@ -2,6 +2,4 @@ name: Riddle Marketplace Module
description: Creation and placing of riddles in Drupal8
package: Riddle
type: module
core_version_requirement: ^8.8 || ^9
dependencies:
- drupal:ckeditor
core_version_requirement: ^9 || ^10
......@@ -70,7 +70,7 @@ class RiddleButton extends CKEditorPluginBase implements CKEditorPluginInterface
* {@inheritdoc}
*/
public function getFile() {
return drupal_get_path('module', 'riddle_marketplace') . '/src/Plugin/CKEditorPlugin/editor_plugin.js';
return \Drupal::service('extension.list.module')->getPath('riddle_marketplace') . '/src/Plugin/CKEditorPlugin/editor_plugin.js';
}
/**
......@@ -81,7 +81,7 @@ class RiddleButton extends CKEditorPluginBase implements CKEditorPluginInterface
return [
'RiddleButton' => [
'label' => 'Riddles',
'image' => drupal_get_path('module', 'riddle_marketplace') . '/images/riddle.jpg',
'image' => \Drupal::service('extension.list.module')->getPath('riddle_marketplace') . '/images/riddle.jpg',
'image_alternative' => 'Riddles',
'attributes' => [],
],
......
......@@ -43,7 +43,7 @@ class RiddleFeedServiceTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->cacheServiceMock = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
......
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