MessengerTrait.php in Drupal 9
Same filename and directory in other branches
Namespace
Drupal\Core\MessengerFile
core/lib/Drupal/Core/Messenger/MessengerTrait.phpView source
<?php
namespace Drupal\Core\Messenger;
/**
* Provides a trait for the messenger service.
*/
trait MessengerTrait {
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Sets the messenger.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public function setMessenger(MessengerInterface $messenger) {
$this->messenger = $messenger;
}
/**
* Gets the messenger.
*
* @return \Drupal\Core\Messenger\MessengerInterface
* The messenger.
*/
public function messenger() {
if (!isset($this->messenger)) {
$this->messenger = \Drupal::messenger();
}
return $this->messenger;
}
}
Traits
Name | Description |
---|---|
MessengerTrait | Provides a trait for the messenger service. |