function MessengerTrait::messenger

Same name in other branches
  1. 9 core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait::messenger()
  2. 8.9.x core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait::messenger()
  3. 10 core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait::messenger()

Gets the messenger.

Return value

\Drupal\Core\Messenger\MessengerInterface The messenger.

File

core/lib/Drupal/Core/Messenger/MessengerTrait.php, line 33

Class

MessengerTrait
Provides a trait for the messenger service.

Namespace

Drupal\Core\Messenger

Code

public function messenger() {
    if (!isset($this->messenger)) {
        $this->messenger = \Drupal::messenger();
    }
    return $this->messenger;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.