You are here

protected function WorkflowTransitionEventSubscriber::setMessage in State Machine 8

Sets a message with event information for test purposes.

Parameters

\Drupal\state_machine\Event\WorkflowTransitionEvent $event: The transition event.

string $phase: The phase during which the event occurred.

6 calls to WorkflowTransitionEventSubscriber::setMessage()
WorkflowTransitionEventSubscriber::onGenericPostTransition in tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php
Reacts to the 'state_machine.post_transition' event.
WorkflowTransitionEventSubscriber::onGenericPreTransition in tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php
Reacts to the 'state_machine.pre_transition' event.
WorkflowTransitionEventSubscriber::onGroupPostTransition in tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php
Reacts to the 'entity_test_with_bundle.post_transition' event.
WorkflowTransitionEventSubscriber::onGroupPreTransition in tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php
Reacts to the 'entity_test_with_bundle.pre_transition' event.
WorkflowTransitionEventSubscriber::onPostTransition in tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php
Reacts to the 'entity_test_with_bundle.create.post_transition' event.

... See full list

File

tests/modules/state_machine_test/src/EventSubscriber/WorkflowTransitionEventSubscriber.php, line 112

Class

WorkflowTransitionEventSubscriber

Namespace

Drupal\state_machine_test\EventSubscriber

Code

protected function setMessage(WorkflowTransitionEvent $event, $phase) {
  $this->messenger
    ->addMessage(new TranslatableMarkup('@entity_label (@field_name) - @state_label at @phase (workflow: @workflow, transition: @transition).', [
    '@entity_label' => $event
      ->getEntity()
      ->label(),
    '@field_name' => $event
      ->getFieldName(),
    '@state_label' => $event
      ->getTransition()
      ->getToState()
      ->getLabel(),
    '@workflow' => $event
      ->getWorkflow()
      ->getId(),
    '@transition' => $event
      ->getTransition()
      ->getId(),
    '@phase' => $phase,
  ]));
}