From 5e3233f91462e45c0930ad855426b9fe73b0e21f Mon Sep 17 00:00:00 2001 From: Eli Zoller <5439169+elizoller@users.noreply.github.com> Date: Wed, 13 Jan 2021 11:46:52 -0700 Subject: [PATCH] multifile media d9 fixes (#820) * multifile media d9 fixes * phpcs fixes --- src/MediaSource/MediaSourceService.php | 2 +- .../Action/AbstractGenerateDerivativeBase.php | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/MediaSource/MediaSourceService.php b/src/MediaSource/MediaSourceService.php index de346115..9399e334 100644 --- a/src/MediaSource/MediaSourceService.php +++ b/src/MediaSource/MediaSourceService.php @@ -363,7 +363,7 @@ class MediaSourceService { } $directory = $this->fileSystem->dirname($content_location); - if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { + if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) { throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable"); } diff --git a/src/Plugin/Action/AbstractGenerateDerivativeBase.php b/src/Plugin/Action/AbstractGenerateDerivativeBase.php index 711b9a17..8c83c2c7 100644 --- a/src/Plugin/Action/AbstractGenerateDerivativeBase.php +++ b/src/Plugin/Action/AbstractGenerateDerivativeBase.php @@ -3,6 +3,7 @@ namespace Drupal\islandora\Plugin\Action; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Session\AccountInterface; @@ -55,6 +56,13 @@ class AbstractGenerateDerivativeBase extends EmitEvent { */ protected $config; + /** + * The entity field manager. + * + * @var \Drupal\Core\Entity\EntityFieldManager + */ + protected $entityFieldManager; + /** * Constructs a EmitEvent action. * @@ -84,6 +92,8 @@ class AbstractGenerateDerivativeBase extends EmitEvent { * The messenger. * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The system file config. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager + * Field Manager service. */ public function __construct( array $configuration, @@ -98,13 +108,15 @@ class AbstractGenerateDerivativeBase extends EmitEvent { MediaSourceService $media_source, TokenInterface $token, MessengerInterface $messenger, - ConfigFactoryInterface $config + ConfigFactoryInterface $config, + EntityFieldManagerInterface $entity_field_manager ) { $this->utils = $utils; $this->mediaSource = $media_source; $this->token = $token; $this->messenger = $messenger; $this->config = $config->get('system.file'); + $this->entityFieldManager = $entity_field_manager; parent::__construct( $configuration, $plugin_id, @@ -135,7 +147,8 @@ class AbstractGenerateDerivativeBase extends EmitEvent { $container->get('islandora.media_source_service'), $container->get('token'), $container->get('messenger'), - $container->get('config.factory') + $container->get('config.factory'), + $container->get('entity_field.manager') ); }