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\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Serializer\SerializerInterface;
@ -74,10 +75,17 @@ class IIIFManifest extends StylePluginBase {
*/
protected $fileSystem;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
private $messenger;
/**
* {@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);
$this->serializer = $serializer;
@ -85,6 +93,7 @@ class IIIFManifest extends StylePluginBase {
$this->iiifConfig = $iiif_config;
$this->fileSystem = $file_system;
$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 (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');
}

20
src/EventGenerator/EmitEvent.php

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

Loading…
Cancel
Save