for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sludio\HelperBundle\Script\Model;
use Symfony\Component\HttpFoundation\Session\Session;
class AlertManager implements AlertManagerInterface
{
private $session;
public function __construct(Session $session)
$this->session = $session;
}
public function addAlert(AlertInterface $alert)
$this->session->getFlashBag()->add($alert->getType(), $alert->getMessage());
public function getAlerts()
$alerts = [];
foreach (self::getAlertTypes() as $type) {
$messages = $this->session->getFlashBag()->get($type);
if (!empty($messages)) {
$alerts = array_merge($alerts, $this->createAlertsForType($type, $messages));
return $alerts;
private function createAlertsForType($type, array $messages)
foreach ($messages as $msg) {
$alerts[] = new Alert($type, $msg);
public static function getAlertTypes()
return [
AlertInterface::SUCCESS,
AlertInterface::ERROR,
AlertInterface::WARNING,
AlertInterface::INFO,
];