Browse Source

update messenger for d9

d9_islandora
elizoller 4 years ago
parent
commit
c44b957eae
  1. 13
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  2. 20
      src/EventGenerator/EmitEvent.php

13
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -4,6 +4,7 @@ namespace Drupal\islandora_iiif\Plugin\views\style;
use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -74,10 +75,17 @@ class IIIFManifest extends StylePluginBase {
*/ */
protected $fileSystem; protected $fileSystem;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
private $messenger;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystem $file_system, Client $http_client) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystem $file_system, Client $http_client, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->serializer = $serializer; $this->serializer = $serializer;
@ -85,6 +93,7 @@ class IIIFManifest extends StylePluginBase {
$this->iiifConfig = $iiif_config; $this->iiifConfig = $iiif_config;
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->httpClient = $http_client; $this->httpClient = $http_client;
$this->messenger = $messenger;
} }
/** /**
@ -297,7 +306,7 @@ class IIIFManifest extends StylePluginBase {
// If no fields to choose from, add an error message indicating such. // If no fields to choose from, add an error message indicating such.
if (count($field_options) == 0) { if (count($field_options) == 0) {
drupal_set_message($this->t('No image or file fields were found in the View. $this->messenger->addMessage($this->t('No image or file fields were found in the View.
You will need to add a field to this View'), 'error'); You will need to add a field to this View'), 'error');
} }

20
src/EventGenerator/EmitEvent.php

@ -5,6 +5,7 @@ namespace Drupal\islandora\EventGenerator;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@ -55,6 +56,13 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
*/ */
protected $auth; protected $auth;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
private $messenger;
/** /**
* Constructs a EmitEvent action. * Constructs a EmitEvent action.
* *
@ -74,6 +82,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
* Stomp client. * Stomp client.
* @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth * @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth
* JWT Auth client. * JWT Auth client.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -83,7 +93,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
EntityTypeManagerInterface $entity_type_manager, EntityTypeManagerInterface $entity_type_manager,
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth JwtAuth $auth,
MessengerInterface $messenger
) { ) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->account = $account; $this->account = $account;
@ -91,6 +102,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
$this->eventGenerator = $event_generator; $this->eventGenerator = $event_generator;
$this->stomp = $stomp; $this->stomp = $stomp;
$this->auth = $auth; $this->auth = $auth;
$this->messenger = $messenger;
} }
/** /**
@ -121,7 +133,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
\Drupal::logger('islandora')->error( \Drupal::logger('islandora')->error(
t('Error getting JWT token for message. Check JWT Configuration.') t('Error getting JWT token for message. Check JWT Configuration.')
); );
drupal_set_message( $this->messenger->addMessage(
t('Error getting JWT token for message. Check JWT Configuration.'), 'error' t('Error getting JWT token for message. Check JWT Configuration.'), 'error'
); );
return; return;
@ -141,7 +153,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
\Drupal::logger('islandora')->error( \Drupal::logger('islandora')->error(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]) t('Error generating event: @msg', ['@msg' => $e->getMessage()])
); );
drupal_set_message( $this->messenger->addMessage(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]), t('Error generating event: @msg', ['@msg' => $e->getMessage()]),
'error' 'error'
); );
@ -162,7 +174,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
); );
// Notify user. // Notify user.
drupal_set_message( $this->messenger->addMessage(
t('Error publishing message: @msg', t('Error publishing message: @msg',
['@msg' => $e->getMessage()] ['@msg' => $e->getMessage()]
), ),

Loading…
Cancel
Save