Browse Source

use dependency injection for messenger and fix other deprecated functions for d9

d9_islandora
Eli Zoller 4 years ago
parent
commit
bba922f637
  1. 22
      src/Plugin/Action/AbstractGenerateDerivative.php
  2. 20
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
  3. 15
      src/Plugin/Action/EmitFileEvent.php
  4. 12
      src/Plugin/Action/EmitMediaEvent.php
  5. 3
      src/Plugin/Condition/FileUsesFilesystem.php
  6. 2
      src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

22
src/Plugin/Action/AbstractGenerateDerivative.php

@ -5,6 +5,7 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
@ -42,6 +43,13 @@ class AbstractGenerateDerivative extends EmitEvent {
*/ */
protected $token; protected $token;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/** /**
* Constructs a EmitEvent action. * Constructs a EmitEvent action.
* *
@ -67,6 +75,8 @@ class AbstractGenerateDerivative extends EmitEvent {
* Media source service. * Media source service.
* @param \Drupal\token\TokenInterface $token * @param \Drupal\token\TokenInterface $token
* Token service. * Token service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -79,7 +89,8 @@ class AbstractGenerateDerivative extends EmitEvent {
JwtAuth $auth, JwtAuth $auth,
IslandoraUtils $utils, IslandoraUtils $utils,
MediaSourceService $media_source, MediaSourceService $media_source,
TokenInterface $token TokenInterface $token,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -89,11 +100,13 @@ class AbstractGenerateDerivative extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->utils = $utils; $this->utils = $utils;
$this->mediaSource = $media_source; $this->mediaSource = $media_source;
$this->token = $token; $this->token = $token;
$this->messenger = $messenger;
} }
/** /**
@ -111,7 +124,8 @@ class AbstractGenerateDerivative extends EmitEvent {
$container->get('jwt.authentication.jwt'), $container->get('jwt.authentication.jwt'),
$container->get('islandora.utils'), $container->get('islandora.utils'),
$container->get('islandora.media_source_service'), $container->get('islandora.media_source_service'),
$container->get('token') $container->get('token'),
$container->get('messenger')
); );
} }
@ -127,7 +141,7 @@ class AbstractGenerateDerivative extends EmitEvent {
'mimetype' => '', 'mimetype' => '',
'args' => '', 'args' => '',
'destination_media_type' => '', 'destination_media_type' => '',
'scheme' => file_default_scheme(), 'scheme' => \Drupal::config('system.file')->get('default_scheme'),
'path' => '[date:custom:Y]-[date:custom:m]/[node:nid].bin', 'path' => '[date:custom:Y]-[date:custom:m]/[node:nid].bin',
]; ];
} }

20
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\islandora\EventGenerator\EmitEvent; use Drupal\islandora\EventGenerator\EmitEvent;
@ -56,6 +57,13 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
*/ */
protected $entityFieldManager; protected $entityFieldManager;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/** /**
* Constructs a EmitEvent action. * Constructs a EmitEvent action.
* *
@ -83,6 +91,8 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
* Token service. * Token service.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* Field Manager service. * Field Manager service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -96,7 +106,8 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
IslandoraUtils $utils, IslandoraUtils $utils,
MediaSourceService $media_source, MediaSourceService $media_source,
Token $token, Token $token,
EntityFieldManagerInterface $entity_field_manager EntityFieldManagerInterface $entity_field_manager,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -106,12 +117,14 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->utils = $utils; $this->utils = $utils;
$this->mediaSource = $media_source; $this->mediaSource = $media_source;
$this->token = $token; $this->token = $token;
$this->entityFieldManager = $entity_field_manager; $this->entityFieldManager = $entity_field_manager;
$this->messenger = $messenger;
} }
/** /**
@ -130,7 +143,8 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
$container->get('islandora.utils'), $container->get('islandora.utils'),
$container->get('islandora.media_source_service'), $container->get('islandora.media_source_service'),
$container->get('token'), $container->get('token'),
$container->get('entity_field.manager') $container->get('entity_field.manager'),
$container->get('messenger')
); );
} }

15
src/Plugin/Action/EmitFileEvent.php

@ -5,8 +5,10 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\islandora\EventGenerator\EmitEvent; use Drupal\islandora\EventGenerator\EmitEvent;
use Drupal\islandora\EventGenerator\EventGeneratorInterface; use Drupal\islandora\EventGenerator\EventGeneratorInterface;
@ -52,6 +54,8 @@ class EmitFileEvent extends EmitEvent {
* JWT Auth client. * JWT Auth client.
* @param \Drupal\Core\File\FileSystemInterface $file_system * @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service. * File system service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -62,7 +66,8 @@ class EmitFileEvent extends EmitEvent {
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth, JwtAuth $auth,
FileSystemInterface $file_system FileSystemInterface $file_system,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -72,7 +77,8 @@ class EmitFileEvent extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
} }
@ -90,7 +96,8 @@ class EmitFileEvent extends EmitEvent {
$container->get('islandora.eventgenerator'), $container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'), $container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'), $container->get('jwt.authentication.jwt'),
$container->get('file_system') $container->get('file_system'),
$container->get('messenger')
); );
} }
@ -99,7 +106,7 @@ class EmitFileEvent extends EmitEvent {
*/ */
protected function generateData(EntityInterface $entity) { protected function generateData(EntityInterface $entity) {
$uri = $entity->getFileUri(); $uri = $entity->getFileUri();
$scheme = $this->fileSystem->uriScheme($uri); $scheme = StreamWrapperManager::getScheme($uri);
$flysystem_config = Settings::get('flysystem'); $flysystem_config = Settings::get('flysystem');
$data = parent::generateData($entity); $data = parent::generateData($entity);

12
src/Plugin/Action/EmitMediaEvent.php

@ -4,6 +4,7 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\islandora\EventGenerator\EmitEvent; use Drupal\islandora\EventGenerator\EmitEvent;
@ -51,6 +52,8 @@ class EmitMediaEvent extends EmitEvent {
* JWT Auth client. * JWT Auth client.
* @param \Drupal\islandora\MediaSource\MediaSourceService $media_source * @param \Drupal\islandora\MediaSource\MediaSourceService $media_source
* Media source service. * Media source service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -61,7 +64,8 @@ class EmitMediaEvent extends EmitEvent {
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth, JwtAuth $auth,
MediaSourceService $media_source MediaSourceService $media_source,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -71,7 +75,8 @@ class EmitMediaEvent extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->mediaSource = $media_source; $this->mediaSource = $media_source;
} }
@ -89,7 +94,8 @@ class EmitMediaEvent extends EmitEvent {
$container->get('islandora.eventgenerator'), $container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'), $container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'), $container->get('jwt.authentication.jwt'),
$container->get('islandora.media_source_service') $container->get('islandora.media_source_service'),
$container->get('messenger')
); );
} }

3
src/Plugin/Condition/FileUsesFilesystem.php

@ -6,6 +6,7 @@ use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -151,7 +152,7 @@ class FileUsesFilesystem extends ConditionPluginBase implements ContainerFactory
*/ */
protected function evaluateFile(FileInterface $file) { protected function evaluateFile(FileInterface $file) {
$uri = $file->getFileUri(); $uri = $file->getFileUri();
$scheme = $this->fileSystem->uriScheme($uri); $scheme = StreamWrapperManager::getScheme($uri);
return !empty($this->configuration['filesystems'][$scheme]); return !empty($this->configuration['filesystems'][$scheme]);
} }

2
src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

@ -124,7 +124,7 @@ class IslandoraImageFormatter extends ImageFormatter {
return $elements; return $elements;
} }
$url = $node->urlInfo(); $url = $node->toUrl()->toString();
foreach ($elements as &$element) { foreach ($elements as &$element) {
$element['#url'] = $url; $element['#url'] = $url;

Loading…
Cancel
Save