You are here

class LegacyMessenger in Service Container 7.2

Same name and namespace in other branches
  1. 8 src/Messenger/LegacyMessenger.php \Drupal\service_container\Messenger\LegacyMessenger
  2. 7 src/Messenger/LegacyMessenger.php \Drupal\service_container\Messenger\LegacyMessenger

Class that manage the messages in Drupal.

Hierarchy

Expanded class hierarchy of LegacyMessenger

2 files declare their use of LegacyMessenger
LegacyMessengerTest.php in tests/src/Messenger/LegacyMessengerTest.php
Contains \Drupal\Tests\service_container\Messenger\LegacyMessengerTest.
LegacyMessengerTest.php in lib/Drupal/service_container/Tests/LegacyMessengerTest.php
Contains \Drupal\service_container\Tests\LegacyMessengerTest.
1 string reference to 'LegacyMessenger'
LegacyMessengerTest::getInfo in lib/Drupal/service_container/Tests/LegacyMessengerTest.php

File

src/Messenger/LegacyMessenger.php, line 15
Contains \Drupal\service_container\LegacyMessenger.

Namespace

Drupal\service_container\Messenger
View source
class LegacyMessenger implements MessengerInterface {

  /**
   * The Drupal 7 legacy service.
   *
   * @var \Drupal\service_container\Legacy\Drupal7
   */
  protected $drupal7;

  /**
   * Constructs a LegacyMessenger object.
   *
   * @param \Drupal\service_container\Legacy\Drupal7 $drupal7_service
   *    The Drupal 7 legacy service.
   */
  public function __construct(Drupal7 $drupal7_service) {
    $this->drupal7 = $drupal7_service;
  }

  /**
   * {@inheritdoc}
   */
  public function addMessage($message, $type = self::STATUS, $repeat = FALSE) {
    $this->drupal7
      ->drupal_set_message($message, $type, $repeat);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getMessages() {
    return $this->drupal7
      ->drupal_get_messages(NULL, FALSE);
  }

  /**
   * {@inheritdoc}
   */
  public function getMessagesByType($type) {
    $messages = $this->drupal7
      ->drupal_get_messages($type, FALSE);
    return isset($messages[$type]) ? $messages[$type] : array();
  }

  /**
   * {@inheritdoc}
   */
  public function deleteMessages() {
    $this->drupal7
      ->drupal_get_messages(NULL, TRUE);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function deleteMessagesByType($type) {
    $this->drupal7
      ->drupal_get_messages($type, TRUE);
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LegacyMessenger::$drupal7 protected property The Drupal 7 legacy service.
LegacyMessenger::addMessage public function Adds a new message to the queue. Overrides MessengerInterface::addMessage
LegacyMessenger::deleteMessages public function Deletes all messages. Overrides MessengerInterface::deleteMessages
LegacyMessenger::deleteMessagesByType public function Deletes all messages of a certain type. Overrides MessengerInterface::deleteMessagesByType
LegacyMessenger::getMessages public function Gets all messages. Overrides MessengerInterface::getMessages
LegacyMessenger::getMessagesByType public function Gets all messages of a certain type. Overrides MessengerInterface::getMessagesByType
LegacyMessenger::__construct public function Constructs a LegacyMessenger object.
MessengerInterface::ERROR constant An error.
MessengerInterface::STATUS constant A status message.
MessengerInterface::WARNING constant A warning.