Bootstrap\View\Helper\BootstrapHtmlHelper::alert PHP Method

alert() public method

Create a Twitter Bootstrap style alert block, containing text.
public alert ( $text, $type = null, $options = [] )
$text The alert text
$type The type of the alert
$options Options that will be passed to Html::div method The second parameter may either be $type or $options (in this case, the third parameter is useless, and the label type can be specified in the $options array). Available BootstrapHtml options: - type: string, type of alert (default, error, info, success ; useless if $type is specified)
    public function alert($text, $type = null, $options = [])
    {
        if (is_string($type)) {
            $options['type'] = $type;
        } else {
            if (is_array($type)) {
                $options = $type;
            }
        }
        $options += ['type' => $this->config('alert.type')];
        $button = $this->tag('button', '×', ['type' => 'button', 'class' => 'close', 'data-dismiss' => 'alert', 'aria-hidden' => true]);
        $type = $options['type'];
        unset($options['type']);
        $options = $this->addClass($options, 'alert');
        if ($type) {
            $options = $this->addClass($options, 'alert-' . $type);
        }
        $class = $options['class'];
        unset($options['class']);
        return $this->div($class, $button . $text, $options);
    }