Rename Notifiation::getMessages() to popMessages()

Because the call to popMessages()--before getMessages()--automatically resets the notification messages on the instance, popMessages() is a much better name for the method.

refs #9660
This commit is contained in:
Eric Lippmann 2015-07-30 13:45:39 +02:00
parent d545e1f7d1
commit 81aad9d6a6
4 changed files with 6 additions and 6 deletions

View File

@ -51,7 +51,7 @@ if (Auth::getInstance()->isAuthenticated()):
<ul id="notifications"><?php
$notifications = Notification::getInstance();
if ($notifications->hasMessages()) {
foreach ($notifications->getMessages() as $m) {
foreach ($notifications->popMessages() as $m) {
echo '<li class="' . $m->type . '">' . $this->escape($m->message) . '</li>';
}
}

View File

@ -455,7 +455,7 @@ class ActionController extends Zend_Controller_Action
$notifications = Notification::getInstance();
if ($notifications->hasMessages()) {
$notificationList = array();
foreach ($notifications->getMessages() as $m) {
foreach ($notifications->popMessages() as $m) {
$notificationList[] = rawurlencode($m->type . ' ' . $m->message);
}
$resp->setHeader('X-Icinga-Notification', implode('&', $notificationList), true);

View File

@ -183,11 +183,11 @@ class Notification
}
/**
* Get the notification messages
* Pop the notification messages
*
* @return array
*/
public function getMessages()
public function popMessages()
{
$messages = $this->messages;
$this->messages = array();

View File

@ -19,7 +19,7 @@ $maxProgress = @max(array_keys(array_filter(
$notifications = Notification::getInstance();
if ($notifications->hasMessages()) {
foreach ($notifications->getMessages() as $m) {
foreach ($notifications->popMessages() as $m) {
echo '<li class="' . $m->type . '">' . $this->escape($m->message) . '</li>';
}
}
@ -135,4 +135,4 @@ if ($notifications->hasMessages()) {
<?= $this->render('index/parts/wizard.phtml'); ?>
<?php endif ?>
</div>
</div>
</div>