本文整理汇总了PHP中yii\web\Session::getAllFlashes方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getAllFlashes方法的具体用法?PHP Session::getAllFlashes怎么用?PHP Session::getAllFlashes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Session
的用法示例。
在下文中一共展示了Session::getAllFlashes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllFlashes
/**
* Returns all flash messages.
*
* You may use this method to display all the flash messages in a view file:
*
* ```php
* <?php
* foreach(Yii::$app->session->getAllFlashes() as $key => $message) {
* echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
* } ?>
* ```
*
* With the above code you can use the [bootstrap alert][] classes such as `success`, `info`, `danger`
* as the flash message key to influence the color of the div.
*
* [bootstrap alert]: http://getbootstrap.com/components/#alerts
*
* @param boolean $delete whether to delete the flash messages right after this method is called.
* If false, the flash messages will be automatically deleted in the next request.
* @return array flash messages (key => message).
* @see setFlash()
* @see getFlash()
* @see hasFlash()
* @see removeFlash()
*/
public function getAllFlashes($delete = false)
{
$this->updateFlashCounters();
return parent::getAllFlashes($delete);
// TODO: Change the autogenerated stub
}
示例2: showFlashes
/**
* Generate flashes message
*
* @param \yii\web\Session $session
*/
protected function showFlashes($session)
{
$flashes = $session->getAllFlashes();
foreach ($flashes as $type => $data) {
$option = $this->getOption($type);
if ($option) {
$data = (array) $data;
foreach ($data as $i => $message) {
$title = $option['title'];
$class = $option['class'];
if ($this->enableIcon) {
$title = Html::tag('i', '', ['class' => $option['icon']]) . $title;
$class .= ' gritter-icon';
}
$this->registerJS($title, $message, $class, '', $this->gritterOptions);
}
$session->removeFlash($type);
}
}
}