Skip to content

Commit

Permalink
Prepare D10 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
dj1999 committed Jan 16, 2024
1 parent b3d36ef commit 1dab233
Show file tree
Hide file tree
Showing 27 changed files with 164 additions and 76 deletions.
29 changes: 16 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,37 @@
}
},
"require": {
"php": ">=7.3",
"php": "^8.1",
"ext-json": "*",
"ext-zip": "*",
"brainsum/damo_theme": ">=0.3 <1.0",
"brainsum/media_upload": "^4.3.0",
"drupal/better_exposed_filters": "^6.0.0",
"brainsum/media_upload": "^4.3",
"drupal/better_exposed_filters": "^6.0",
"drupal/core": "^10.0",
"drupal/dropzonejs": "^2.7.0",
"drupal/entity_browser": "^2.9.0",
"drupal/dropzonejs": "^2.7",
"drupal/entity_browser": "^2.9",
"drupal/entity_embed": "^1.5",
"drupal/exif": "^2.5",
"drupal/field_group": "^3.4.0",
"drupal/filehash": "^2.0",
"drupal/field_group": "^3.4",
"drupal/filehash": "2.0",
"drupal/focal_point": "^2.0",
"drupal/image_effects": "^3.4.0",
"drupal/image_effects": "^3.4",
"drupal/inline_entity_form": "^3.0@RC",
"drupal/jsonapi_extras": "^3.23.0",
"drupal/jsonapi_extras": "^3.23",
"drupal/maxlength": "2.1.x-dev@dev",
"drupal/media_entity_imagemagick": "^3.0@alpha",
"drupal/php_ffmpeg": "^1.1.0",
"drupal/redirect_after_login": "^2.7.0",
"drupal/search_api": "^1.28.0",
"drupal/select2": "^1.14.0",
"drupal/taxonomy_access_fix": "^4.0.0",
"drupal/search_api": "^1.28",
"drupal/select2": "^1.14",
"drupal/taxonomy_access_fix": "^4.0",
"drupal/term_merge": "2.0.x-dev@dev",
"drupal/term_reference_change": "2.x-dev@dev",
"drupal/userprotect": "^1.2.0",
"drupal/video_embed_field": "^2.5.0"
"drupal/video_embed_field": "^2.5.0",
"npm-asset/dropzone": "^5.7.6",
"npm-asset/jquery-ui-touch-punch": "^0.2.3",
"npm-asset/select2": "^4.0.13"
},
"suggest": {
"drupal/maillog": "Allows logging outgoing emails.",
Expand Down
4 changes: 2 additions & 2 deletions damopen.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: 'Digital Media Assets Management'
type: profile
description: 'Distribution for quickly starting a new Digital Media Assets Management system with Drupal'

core_version_requirement: ^9.1
php: 7.3
core_version_requirement: ^9.1 || ^10.0
php: 8.1

distribution:
name: 'Digital Media Assets Management'
Expand Down
2 changes: 1 addition & 1 deletion modules/damopen_assets/damopen_assets.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Media Assets"
type: module
description: Media assets functionality

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'
dependencies:
Expand Down
5 changes: 3 additions & 2 deletions modules/damopen_assets/src/Form/BulkMediaUploadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static function create(ContainerInterface $container) {
$container->get('entity_field.manager'),
$container->get('logger.factory'),
$container->get('token'),
$container->get('file_system')
$container->get('file_system'),
$container->get('file.repository')
);
}

Expand Down Expand Up @@ -211,7 +212,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

$destination = $targetDirectory . '/' . $file['filename'];
$data = file_get_contents($file['path']);
$fileEntity = file_save_data($data, $destination);
$fileEntity = $this->fileRepository->writeData($data, $destination);

if (FALSE === $fileEntity) {
$errorFlag = TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ protected function mediaCount(array $types): int {
->condition('bundle', $types, 'in')
->condition('status', 1)
->count()
->accessCheck(FALSE)
->execute();
}
catch (Exception $exception) {
Expand Down
2 changes: 1 addition & 1 deletion modules/damopen_assets_api/damopen_assets_api.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Media Assets API'
type: module
description: 'Media assets API functionality'

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
27 changes: 16 additions & 11 deletions modules/damopen_assets_api/src/Field/ImageStyleDownloadUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TraversableTypedDataInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use RuntimeException;
use function file_url_transform_relative;
Expand All @@ -32,19 +33,23 @@ class ImageStyleDownloadUrl extends FieldItemList {
*/
protected $imageStyleStorage;

/**
* File URL generator.
*
* @var \Drupal\Core\File\FileUrlGeneratorInterface
*/
protected $fileUrlGenerator;

/**
* {@inheritdoc}
*/
public function __construct(
DataDefinitionInterface $definition,
$name = NULL,
TypedDataInterface $parent = NULL
) {
parent::__construct($definition, $name, $parent);

// @todo: Dep.inj.
// @see: https://www.drupal.org/project/drupal/issues/2053415
$this->imageStyleStorage = Drupal::entityTypeManager()->getStorage('image_style');
public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
$instance = parent::createInstance($definition, $name, $parent);
$instance->imageStyleStorage = Drupal::entityTypeManager()
->getStorage('image_style');
$instance->fileUrlGenerator = Drupal::service('file_url_generator');

return $instance;
}

/**
Expand All @@ -64,7 +69,7 @@ protected function fileCreateThumbnailUrl($uri): string {
}

$url = $style->buildUrl($uri);
return file_url_transform_relative(file_create_url($url));
return $this->fileUrlGenerator->generateString($url);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function normalize($entity, $format = NULL, array $context = []) {
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
$attributes = [];
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
foreach ($entity as $name => $field) {
foreach ($object as $name => $field) {
if (!$field->access('view', $context['account'] ?? NULL)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function get($media_entity_id = NULL) {
/** @var int[] $media_ids */
$media_ids = $this->mediaStorage->getQuery()
->condition('status', 1, '=')
->accessCheck(FALSE)
->execute();

/** @var \Drupal\media\MediaInterface[] $media_data */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Media Assets download"
type: module
description: Media assets download functionality

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Media Assets Library"
type: module
description: Media assets library functionality.

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'
dependencies:
Expand Down
13 changes: 9 additions & 4 deletions modules/damopen_assets_library/damopen_assets_library.install
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@ function damopen_assets_library_update_8004() {
$configStorage->write($config, $source->read($config));
}

// @todo: How to handle this? Require dbee?
module_load_include('inc', 'dbee', 'dbee.users');
dbee_update_crypt_all('encrypt');
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler */
$moduleHandler = Drupal::moduleHandler();
if ($moduleHandler->moduleExists('dbee')) {
// @todo: How to handle this? Require dbee?
\Drupal::moduleHandler()->loadInclude('dbee', 'inc', 'dbee.users');
dbee_update_crypt_all('encrypt');
}
}

/**
Expand Down Expand Up @@ -286,7 +290,8 @@ function _damopen_assets_library_field_encryption() {
$queue->releaseItem($item);
}
catch (Exception $e) {
watchdog_exception('field_encrypt', $e);
$logger = \Drupal::logger('field_encrypt');
\Drupal\Core\Utility\Error::logException($logger, $e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Image media lister"
type: module
description: "Lister for assets."

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Media Statistics"
type: module
description: Media statistics.

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'
dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Media Asset Thumbnails"
type: module
description: Media assets thumbnails functionality

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ services:
- '@current_user'
- '@config.factory'
- '@stream_wrapper_manager'
- '@file_url_generator'
15 changes: 13 additions & 2 deletions modules/damopen_assets_thumbnails/src/Service/VideoThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StreamWrapper\LocalStream;
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
Expand Down Expand Up @@ -71,6 +72,13 @@ class VideoThumbnail {
*/
protected $streamWrapperManager;

/**
* File URL generator.
*
* @var \Drupal\Core\File\FileUrlGeneratorInterface
*/
protected $fileUrlGenerator;

/**
* VideoThumbnail constructor.
*
Expand All @@ -96,7 +104,8 @@ public function __construct(
EntityTypeManagerInterface $entityTypeManager,
AccountProxyInterface $currentUser,
ConfigFactoryInterface $configFactory,
StreamWrapperManagerInterface $streamWrapperManager
StreamWrapperManagerInterface $streamWrapperManager,
FileUrlGeneratorInterface $fileUrlGenerator
) {
$this->ffMpeg = $ffMpeg;
$this->fileSystem = $fileSystem;
Expand All @@ -106,6 +115,7 @@ public function __construct(
->get('system.file')
->get('default_scheme');
$this->streamWrapperManager = $streamWrapperManager;
$this->fileUrlGenerator = $fileUrlGenerator;
}

/**
Expand Down Expand Up @@ -211,7 +221,8 @@ protected function sourceUri(FileInterface $video): string {
return $video->getFileUri();
}

return file_create_url($video->getFileUri());
return $this->fileUrlGenerator
->generateAbsoluteString($video->getFileUri());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/damopen_common/damopen_common.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: 'DAMo - Common features'
type: module
description: 'DAMo common features.'

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Default content for DAMo"
type: module
description: "Adds default content"

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Image media styles preview"
type: module
description: "Adds a style preview feature for Image media entities"

core_version_requirement: ^9.1
core_version_requirement: ^9.1 || ^10.0

package: 'Digital Assets Management'

Expand Down
Loading

0 comments on commit 1dab233

Please sign in to comment.