public function add($type, $message, $flash = true, $format = null)
{
if (!$this->typeIsAvailable($type)) {
return $this;
}
if ($message instanceof \Krucas\Notification\Message) {
$m = $message;
$this->addInstance($m, $type, $flash, $format);
} elseif ($message instanceof Closure) {
$m = new Message($type, null, $flash, $format);
call_user_func_array($message, [$m]);
$this->addInstance($m, $type, $flash, $format);
} else {
$m = new Message($type, $message, $flash, $this->checkFormat($format, $type));
}
if (!$m->isFlash()) {
$this->notifications->add($m);
$this->fireEvent('added', $m);
} else {
$this->fireEvent('flash', $m);
}
return $this;
}