MessengerTrait.php
Same filename in other branches
Namespace
Drupal\Core\MessengerFile
-
core/
lib/ Drupal/ Core/ Messenger/ MessengerTrait.php
View 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
Title | Deprecated | Summary |
---|---|---|
MessengerTrait | Provides a trait for the messenger service. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.