Commit b9e9ac6e authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Ajout des modifications du messenger pour pouvoir faire fonctionner le mouchard

parent 3dd876e1
......@@ -5,6 +5,8 @@ use Exception;
use UnicaenApp\Traits\MessageAwareInterface;
use UnicaenApp\Traits\MessageAwareTrait;
use UnicaenApp\Exception\LogicException;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerAwareTrait;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\FlashMessenger;
use Zend\View\Helper\HtmlTag;
......@@ -19,8 +21,11 @@ use Zend\View\Renderer\PhpRenderer;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class Messenger extends AbstractHelper implements MessageAwareInterface
class Messenger extends AbstractHelper implements MessageAwareInterface, EventManagerAwareInterface
{
const EVENT_RENDER = 'unicaen-app-messenger-render';
use EventManagerAwareTrait;
use MessageAwareTrait;
const NAMESPACED_SEVERITY_SEPARATOR = '/';
......@@ -103,10 +108,14 @@ class Messenger extends AbstractHelper implements MessageAwareInterface
foreach ($this->getSortedMessages() as $severity => $array) {
foreach ($array as $priority => $message) {
if ($em = $this->getEventManager()){
$em->trigger(self::EVENT_RENDER, null, compact('severity','message'));
}
$out .= sprintf(
$this->getTemplate(is_string($severity) ? $severity : (is_string($priority) ? $priority : 'info')),
implode('<br />', (array)$message)
);
);;
}
}
......
<?php
namespace UnicaenApp\View\Helper;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of MessengerFactory
*
* @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
*/
class MessengerFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $helperPluginManager
* @return Messenger
*/
public function createService(ServiceLocatorInterface $helperPluginManager)
{
$messenger = new Messenger();
/* @var $application Application */
$application = $helperPluginManager->getServiceLocator()->get('application');
if ($application){
$messenger->setEventManager($application->getEventManager());
}
return $messenger;
}
}
\ No newline at end of file
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