You are here

public function Message::execute in Entity Legal 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityLegal/Message.php \Drupal\entity_legal\Plugin\EntityLegal\Message::execute()
  2. 4.0.x src/Plugin/EntityLegal/Message.php \Drupal\entity_legal\Plugin\EntityLegal\Message::execute()

Execute callback for Entity Legal method plugin.

Parameters

array $context: Contextual information for plugin to execute on.

Overrides EntityLegalPluginInterface::execute

File

src/Plugin/EntityLegal/Message.php, line 22

Class

Message
Method class for alerting existing users via Drupal set message.

Namespace

Drupal\entity_legal\Plugin\EntityLegal

Code

public function execute(array &$context = []) {

  /** @var \Drupal\entity_legal\EntityLegalDocumentInterface $document */
  foreach ($this->documents as $document) {
    $message = t('Please accept the @document_name.', [
      '@document_name' => Link::createFromRoute($document
        ->getPublishedVersion()
        ->label(), 'entity.entity_legal_document.canonical', [
        'entity_legal_document' => $document
          ->id(),
      ])
        ->toString(),
    ]);
    \Drupal::messenger()
      ->addWarning($message);
  }
}