'alert-danger', 'danger' => 'alert-danger', 'success' => 'alert-success', 'info' => 'alert-info', 'warning' => 'alert-warning' ]; public function run() { $session = Yii::$app->session; $flashes = $session->getAllFlashes(); foreach ($flashes as $type => $flash) { if (!isset($this->alertTypes[$type])) { continue; } foreach ((array) $flash as $i => $message) { $html = << {$message} HTML; echo $html; } $session->removeFlash($type); } } }