Commit 99aa035a authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Aide de vue Messenger : possibilité de spécifier des classes CSS à ajouter à la div externe.

parent 1430346c
......@@ -7,6 +7,7 @@ use UnicaenApp\Traits\MessageAwareTrait;
use UnicaenApp\Exception\LogicException;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\FlashMessenger;
use Zend\View\Helper\HtmlTag;
use Zend\View\Renderer\PhpRenderer;
/**
......@@ -52,6 +53,11 @@ class Messenger extends AbstractHelper implements MessageAwareInterface
*/
protected $containerInnerTemplate = '%s';
/**
* @var array
*/
protected $containerClassesToAdd = [];
/**
* @var \Zend\Mvc\Controller\Plugin\FlashMessenger
*/
......@@ -368,9 +374,10 @@ class Messenger extends AbstractHelper implements MessageAwareInterface
$iconMarkup = $this->withIcon ? "<span class=\"glyphicon glyphicon-$iconClass\"></span>" : null;
$containerId = $containerId ? sprintf('id="%s"', $containerId) : '';
$classesToAdd = $this->containerClassesToAdd ? implode(' ', $this->containerClassesToAdd) : '';
$template = <<<EOT
<div class="messenger alert alert-$alertClass" $containerId>
<div class="messenger alert alert-$alertClass $classesToAdd" $containerId>
<button type="button" class="close" title="Fermer cette alerte" data-dismiss="alert">&times;</button>
$iconMarkup
$innerTemplate
......@@ -380,6 +387,17 @@ EOT;
return $template . PHP_EOL;
}
/**
* @param array|string $containerClassesToAdd Ex: ['alert-md']
* @return static
*/
public function setContainerClassesToAdd($containerClassesToAdd)
{
$this->containerClassesToAdd = (array) $containerClassesToAdd;
return $this;
}
/**
*
* @param string $containerInnerTemplate
......
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