Browse Source

More context.

pull/839/head
Adam Vessey 5 years ago
parent
commit
11bdc0e1a2
  1. 32
      src/Event/StompHeaderEvent.php
  2. 16
      src/Event/StompHeaderEventInterface.php
  3. 2
      src/EventGenerator/EmitEvent.php
  4. 3
      src/EventSubscriber/StompHeaderSubscriber.php

32
src/Event/StompHeaderEvent.php

@ -27,6 +27,20 @@ class StompHeaderEvent implements StompHeaderEventInterface {
*/ */
protected $user; protected $user;
/**
* An array of data to be sent with the STOMP request, for context.
*
* @var array
*/
protected $data;
/**
* An array of configuration used to generate $data, for context.
*
* @var array
*/
protected $configuration;
/** /**
* The set of headers. * The set of headers.
* *
@ -37,9 +51,11 @@ class StompHeaderEvent implements StompHeaderEventInterface {
/** /**
* Constructor. * Constructor.
*/ */
public function __construct(EntityInterface $entity, AccountInterface $user) { public function __construct(EntityInterface $entity, AccountInterface $user, array $data, array $configuration) {
$this->entity = $entity; $this->entity = $entity;
$this->user = $user; $this->user = $user;
$this->data = $data;
$this->configuration = $configuration;
$this->headers = new ParameterBag(); $this->headers = new ParameterBag();
} }
@ -57,6 +73,13 @@ class StompHeaderEvent implements StompHeaderEventInterface {
return $this->user; return $this->user;
} }
/**
* {@inheritdoc}
*/
public function getData() {
return $this->data;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -64,4 +87,11 @@ class StompHeaderEvent implements StompHeaderEventInterface {
return $this->headers; return $this->headers;
} }
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
} }

16
src/Event/StompHeaderEventInterface.php

@ -37,4 +37,20 @@ interface StompHeaderEventInterface {
*/ */
public function getUser(); public function getUser();
/**
* Fetch the data to be sent in the body of the request.
*
* @return array
* The array of data.
*/
public function getData();
/**
* Fetch the configuration of the action, for context.
*
* @return array
* The array of configuration for the upstream action.
*/
public function getConfiguration();
} }

2
src/EventGenerator/EmitEvent.php

@ -135,7 +135,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
$event = $this->eventDispatcher->dispatch( $event = $this->eventDispatcher->dispatch(
StompHeaderEvent::EVENT_NAME, StompHeaderEvent::EVENT_NAME,
new StompHeaderEvent($entity, $user) new StompHeaderEvent($entity, $user, $data, $this->getConfiguration())
); );
$message = new Message( $message = new Message(

3
src/EventSubscriber/StompHeaderSubscriber.php

@ -6,6 +6,7 @@ use Drupal\islandora\Event\StompHeaderEventInterface;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@ -15,6 +16,8 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/ */
class StompHeaderEventSubscriber implements EventSubscriberInterface { class StompHeaderEventSubscriber implements EventSubscriberInterface {
use StringTranslationTrait;
/** /**
* The JWT auth service. * The JWT auth service.
* *

Loading…
Cancel
Save