src/TwbBundle/View/Helper/TwbBundleAlert.php
public function render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false)
    {
        if (!is_scalar($sAlertMessage)) {
            throw new InvalidArgumentException('Alert message expects a scalar value, "' . gettype($sAlertMessage) . '" given');
        }

        if (empty($aAlertAttributes)) {
            $aAlertAttributes = array('class' => 'alert');
        } elseif (is_string($aAlertAttributes)) {
            $aAlertAttributes = array('class' => $aAlertAttributes);
        } elseif (!is_array($aAlertAttributes)) {
            throw new InvalidArgumentException('Alert attributes expects a string or an array, "' . gettype($aAlertAttributes) . '" given');
        } elseif (empty($aAlertAttributes['class'])) {
            throw new InvalidArgumentException('Alert "class" attribute is empty');
        } elseif (!is_string($aAlertAttributes['class'])) {
            throw new InvalidArgumentException('Alert "class" attribute expects string, "' . gettype($aAlertAttributes) . '" given');
        }

        if (!preg_match('/(\s|^)alert(\s|$)/', $aAlertAttributes['class'])) {
            $aAlertAttributes['class'] .= ' alert';
        }

        if (null !== ($oTranslator = $this->getTranslator())) {
            $sAlertMessage = $oTranslator->translate($sAlertMessage, $this->getTranslatorTextDomain());
        }

        if ($bDismissable) {
            $sAlertMessage = static::$dismissButtonFormat . $sAlertMessage;
            if (!preg_match('/(\s|^)alert-dismissable(\s|$)/', $aAlertAttributes['class'])) {
                $aAlertAttributes['class'] .= ' alert-dismissable';
            }
        }

        return sprintf(
            static::$alertFormat,
            $this->createAttributesString($aAlertAttributes),
            $sAlertMessage
        );
    }
public function render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false)
    {
        if (!is_scalar($sAlertMessage)) {
            throw new InvalidArgumentException('Alert message expects a scalar value, "' . gettype($sAlertMessage) . '" given');
        }

        if (empty($aAlertAttributes)) {
            $aAlertAttributes = array('class' => 'alert');
        } elseif (is_string($aAlertAttributes)) {
            $aAlertAttributes = array('class' => $aAlertAttributes);
        } elseif (!is_array($aAlertAttributes)) {
            throw new InvalidArgumentException('Alert attributes expects a string or an array, "' . gettype($aAlertAttributes) . '" given');
        } elseif (empty($aAlertAttributes['class'])) {
            throw new InvalidArgumentException('Alert "class" attribute is empty');
        } elseif (!is_string($aAlertAttributes['class'])) {
            throw new InvalidArgumentException('Alert "class" attribute expects string, "' . gettype($aAlertAttributes) . '" given');
        }

        if (!preg_match('/(\s|^)alert(\s|$)/', $aAlertAttributes['class'])) {
            $aAlertAttributes['class'] .= ' alert';
        }

        if (null !== ($oTranslator = $this->getTranslator())) {
            $sAlertMessage = $oTranslator->translate($sAlertMessage, $this->getTranslatorTextDomain());
        }

        if ($bDismissable) {
            $sAlertMessage = static::$dismissButtonFormat . $sAlertMessage;
            if (!preg_match('/(\s|^)alert-dismissable(\s|$)/', $aAlertAttributes['class'])) {
                $aAlertAttributes['class'] .= ' alert-dismissable';
            }
        }

        return sprintf(
            static::$alertFormat,
            $this->createAttributesString($aAlertAttributes),
            $sAlertMessage
        );
    }
Retrieve alert markup
@param string $sAlertMessage
@param  string|array $aAlertAttributes : [optionnal] if string, alert class
@param boolean $bDismissable
@throws InvalidArgumentException
@return string