Skip to content

Commit

Permalink
Drupal 10 compatibility (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Fritsch <[email protected]>
  • Loading branch information
chrfritsch and Christian Fritsch authored Mar 22, 2023
1 parent 080a7cc commit a4c03be
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion dcx_integration.info.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DC-X integration
type: module
description: 'Integration of DC-X digital asset management.'
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
2 changes: 1 addition & 1 deletion modules/dcx_article_archive/dcx_article_archive.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Article Archive
type: module
description: Archive Articles to DC-X
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_integration
Expand Down
2 changes: 1 addition & 1 deletion modules/dcx_article_import/dcx_article_import.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Article Import
type: module
description: Allow importing DC-X story documents to article nodes.
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_integration
Expand Down
2 changes: 1 addition & 1 deletion modules/dcx_collections/dcx_collections.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Collections
type: module
description: Integrates DC-X collections to entity browser
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: Custom
dependencies:
- dcx_integration:dcx_migration
2 changes: 1 addition & 1 deletion modules/dcx_dropzone_ui/dcx_dropzone_ui.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Dropzone UI
type: module
description: 'Dropzone Element for DCX DnD'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_migration
2 changes: 1 addition & 1 deletion modules/dcx_entity_browser/dcx_entity_browser.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Entity Browser
type: module
description: 'Entity Browser integration for dcx'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx

dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X media image clone
type: module
description: Allow cloning media image entities and keep track of the clones regarding DC-X.
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_migration
2 changes: 1 addition & 1 deletion modules/dcx_migration/dcx_migration.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Migration
type: module
description: 'Migration of data from DC-X digital asset management.'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_integration
Expand Down
2 changes: 1 addition & 1 deletion modules/dcx_notification/dcx_notification.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X notification
type: module
description: Provides a notification callback to be triggered by DC-X on change of relevant documents.
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_migration
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Track Media Usage
type: module
description: Provides usage tracking of DC-X media an nodes
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- dcx_integration:dcx_integration
2 changes: 1 addition & 1 deletion modules/dcx_unpublish_media/dcx_unpublish_media.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DC-X Unpublish Media
type: module
description: 'Handels the behavior if a media is unpublished'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
package: dcx
dependencies:
- drupal:media (>= 8.4)
4 changes: 2 additions & 2 deletions modules/dcx_unpublish_media/dcx_unpublish_media.module
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function dcx_unpublish_media_media_update(MediaInterface $entity) {

// Do not care about image styles here. File move takes care of this by
// invoking hook image_file_move().
file_move($file, $target_fileuri);
\Drupal::service('file.repository')->move($file, $target_fileuri);
}
elseif ($entity->status->value && !$entity->original->status->value) {
$target_fileuri = str_replace('private://', 'public://', $file->getFileUri());
Expand All @@ -44,7 +44,7 @@ function dcx_unpublish_media_media_update(MediaInterface $entity) {
if (!is_dir($target_dir)) {
mkdir($target_dir);
}
file_move($file, $target_fileuri);
\Drupal::service('file.repository')->move($file, $target_fileuri);

/** @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache */
$cache = \Drupal::service('cache_tags.invalidator');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\StreamWrapper\PublicStream;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -71,6 +71,7 @@ public function kernelRequest(Event $event) {

$query = $this->entityTypeManager->getStorage('file')->getQuery();
$query->condition('filename', $filename);
$query->accessCheck(FALSE);
$fids = $query->execute();

if ($fids) {
Expand All @@ -82,6 +83,7 @@ public function kernelRequest(Event $event) {

$query = $this->entityTypeManager->getStorage('media')->getQuery();
$query->condition("$field.target_id", current($fids));
$query->accessCheck(FALSE);
$mids = $query->execute();

if ($mids) {
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Image extends BaseAsset {
*/
public function __construct(array $data) {
parent::__construct($data, self::$mandatoryAttributes, self::$optionalAttributes);
$mimeType = \Drupal::service('file.mime_type.guesser')->guess($data['url']);
$mimeType = \Drupal::service('file.mime_type.guesser')->guessMimeType($data['url']);
if (!in_array($mimeType, static::$allowedMimeTypes)) {
throw new IllegalAttributeException($data['url']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/AssetGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AssetGenerationTest extends KernelTestBase {
/**
*
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$user = $this->createMock('\Drupal\Core\Session\AccountProxyInterface');

Expand Down
9 changes: 4 additions & 5 deletions tests/src/Kernel/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Drupal\dcx_integration\Asset\Image;
use Drupal\dcx_integration\Asset\Article;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\UnitTestCase;

/**
* Description of AssetTest.
Expand All @@ -25,7 +24,7 @@ public function testCreateImage__mandatory_attr() {
}
$asset = new Image($data);

$this->assertArraySubset($data, $asset->data(), "Mandatory attributes suffice to create an Image");
$this->assertEquals($data, $asset->data(), "Mandatory attributes suffice to create an Image");
}

/**
Expand All @@ -38,7 +37,7 @@ public function testCreateImage__optional_attr() {
}
$asset = new Image($data);

$this->assertArraySubset($data, $asset->data(), "Mandatory and optional attributes are able to create an Image");
$this->assertEquals($data, $asset->data(), "Mandatory and optional attributes are able to create an Image");
}

/**
Expand Down Expand Up @@ -81,7 +80,7 @@ public function testCreateArticle__mandatory_attr() {
}
$asset = new Article($data);

$this->assertArraySubset($data, $asset->data(), "Mandatory attributes suffice to create an Article");
$this->assertEquals($data, $asset->data(), "Mandatory attributes suffice to create an Article");
}

/**
Expand All @@ -94,7 +93,7 @@ public function testCreateArticle__optional_attr() {
}
$asset = new Article($data);

$this->assertArraySubset($data, $asset->data(), "Mandatory and optional attributes are able to create an Article");
$this->assertEquals($data, $asset->data(), "Mandatory and optional attributes are able to create an Article");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/DcxJsonClientIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DcxJsonClientIntegrationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public function setUp() {
public function setUp(): void {
parent::setUp();

$siteSettings = ['mail' => '[email protected]', 'name' => 'Integration Test'];
Expand Down
12 changes: 6 additions & 6 deletions tests/src/Unit/DcxJsonClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DcxJsonClientTest extends UnitTestCase {
/**
*
*/
public function setUp() {
public function setUp(): void {
$jsonclientsettings = ['publication' => 'dummy_publication'];
$config_factory = $this->getConfigFactoryStub(['dcx_integration.jsonclientsettings' => $jsonclientsettings]);
$user = $this->createMock('\Drupal\Core\Session\AccountProxyInterface');
Expand All @@ -42,7 +42,7 @@ public function setUp() {
*/
public function testGetJson_noparams() {
$this->client->getJson('dcxapi:id');
list($url, $params,) = $this->api_client->args;
[$url, $params,] = $this->api_client->args;
$this->assertEquals($this->api_client->method, 'get', 'getObject method of API client is called.');
$this->assertEquals($url, 'id', 'Client disposes "dcxapi:" part of the id.');
$this->assertNotEmpty($params, 'If no params are given, default params are passed to the API client.');
Expand All @@ -53,8 +53,8 @@ public function testGetJson_noparams() {
*/
public function testGetJson_custom_params() {
$this->client->getJson('dcxapi:id', ['params']);
list(, $params,) = $this->api_client->args;
$this->assertArrayEquals(['params'], $params, 'If params are given, they are passed to the API client');
[, $params,] = $this->api_client->args;
$this->assertEquals(['params'], $params, 'If params are given, they are passed to the API client');
}

/**
Expand Down Expand Up @@ -200,9 +200,9 @@ public function testArchiveArticle_exisitingArticle() {
public function testPubinfoOnPath_noResults() {
$this->api_client->expected_response_body = ['entries' => []];
$pubinfos = $this->client->pubinfoOnPath('node/1', 'article');
$this->assertArrayEquals([], $pubinfos);
$this->assertEquals([], $pubinfos);
$this->assertEquals($this->api_client->method, 'get', 'getObject is called when retrieving pubinfo data');
list($url) = $this->api_client->args;
[$url] = $this->api_client->args;
$this->assertEquals($url, 'pubinfo', 'url "pubinfo is requested"');
}

Expand Down

0 comments on commit a4c03be

Please sign in to comment.