trait MessengerTrait
Same name in other branches
- 9 core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait
- 8.9.x core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait
- 11.x core/lib/Drupal/Core/Messenger/MessengerTrait.php \Drupal\Core\Messenger\MessengerTrait
Provides a trait for the messenger service.
Hierarchy
- trait \Drupal\Core\Messenger\MessengerTrait
8 files declare their use of MessengerTrait
- BlockPluginTrait.php in core/
lib/ Drupal/ Core/ Block/ BlockPluginTrait.php - ControllerBase.php in core/
lib/ Drupal/ Core/ Controller/ ControllerBase.php - EntityListBuilder.php in core/
lib/ Drupal/ Core/ Entity/ EntityListBuilder.php - FormBase.php in core/
lib/ Drupal/ Core/ Form/ FormBase.php - FormErrorHandler.php in core/
lib/ Drupal/ Core/ Form/ FormErrorHandler.php
File
-
core/
lib/ Drupal/ Core/ Messenger/ MessengerTrait.php, line 8
Namespace
Drupal\Core\MessengerView source
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;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
MessengerTrait::$messenger | protected | property | The messenger. | 16 |
MessengerTrait::messenger | public | function | Gets the messenger. | 16 |
MessengerTrait::setMessenger | public | function | Sets the messenger. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.