Commit 35f87c2e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

AJout setter pour exception.

parent e60fd547
......@@ -133,6 +133,22 @@ class Messenger extends AbstractHelper
return $this;
}
/**
* Spécifie l'unique message courant au format Exception.
*
* @param \Exception $exception Exception
* @param string $severity Ex: Messenger::INFO
* @return Messenger
*/
public function setException(\Exception $exception, $severity = self::ERROR)
{
$message = sprintf("<p><strong>%s</strong></p>", $exception->getMessage());
if (($previous = $exception->getPrevious())) {
$message .= sprintf("<p>Cause :<br />%s</p>", $previous->getMessage());
}
return $this->setMessages(array($severity => $message));
}
/**
* Spécifie les messages courants (remplaçant les messages existants).
......@@ -239,11 +255,11 @@ class Messenger extends AbstractHelper
$containerId = $containerId ? sprintf('id="%s"', $containerId) : '';
$template = <<<EOT
<p class="messenger alert alert-{$this->uiClasses[$severity][0]}" {$containerId}>
<div class="messenger alert alert-{$this->uiClasses[$severity][0]}" {$containerId}>
<button type="button" class="close" data-dismiss="alert">&times;</button>
<!--<i class="icon-{$this->uiClasses[$severity][1]}"></i>-->
$innerTemplate
</p>
</div>
EOT;
return $template . PHP_EOL;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment