macgyer\yii2materializecss\widgets\Alert::run PHP Method

run() public method

Executes the widget.
public run ( ) : string
return string the result of widget execution to be outputted.
    public function run()
    {
        $flashes = Yii::$app->session->getAllFlashes();
        $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
        foreach ($flashes as $type => $data) {
            if (isset($this->alertLevels[$type])) {
                $data = (array) $data;
                foreach ($data as $i => $message) {
                    /* initialize css class for each alert box */
                    $this->options['class'] = 'alert ' . $this->alertLevels[$type] . $appendCss;
                    /* assign unique id to each alert box */
                    $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
                    echo $this->renderHtml($message, $this->options);
                }
                Yii::$app->session->removeFlash($type);
            }
        }
    }