You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-04-05 12:32:55 +01:00
rename builder dispatch method to flash and add addFlash method
This commit is contained in:
@@ -26,7 +26,8 @@ use Flasher\Prime\Stamp\StampInterface;
|
||||
* @method NotificationBuilderInterface error($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface info($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface warning($message = null, array $options = array())
|
||||
* @method Envelope dispatch(StampInterface[] $stamps)
|
||||
* @method Envelope flash(StampInterface[] $stamps)
|
||||
* @method Envelope addFlash(string|Envelope $type, string $message = null, array $options = array())
|
||||
* @method NotificationInterface getNotification()
|
||||
* @method NotificationInterface getEnvelope()
|
||||
*/
|
||||
|
||||
+10
@@ -5,6 +5,7 @@ namespace Flasher\Prime;
|
||||
use Flasher\Prime\Manager\AbstractManager;
|
||||
use Flasher\Prime\Notification\NotificationBuilderInterface;
|
||||
use Flasher\Prime\Notification\NotificationInterface;
|
||||
use Flasher\Prime\Stamp\StampInterface;
|
||||
|
||||
/**
|
||||
* @method NotificationBuilderInterface type($type, $message = null, array $options = array())
|
||||
@@ -12,11 +13,20 @@ use Flasher\Prime\Notification\NotificationInterface;
|
||||
* @method NotificationBuilderInterface options($options)
|
||||
* @method NotificationBuilderInterface setOption($name, $value)
|
||||
* @method NotificationBuilderInterface unsetOption($name)
|
||||
* @method NotificationBuilderInterface handler(string $handler)
|
||||
* @method NotificationBuilderInterface with(StampInterface[] $stamps)
|
||||
* @method NotificationBuilderInterface withStamp(StampInterface $stamp)
|
||||
* @method NotificationBuilderInterface priority($priority)
|
||||
* @method NotificationBuilderInterface hops($amount)
|
||||
* @method NotificationBuilderInterface keep()
|
||||
* @method NotificationBuilderInterface success($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface error($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface info($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface warning($message = null, array $options = array())
|
||||
* @method Envelope flash(StampInterface[] $stamps)
|
||||
* @method Envelope addFlash(string|Envelope $type, string $message = null, array $options = array())
|
||||
* @method NotificationInterface getNotification()
|
||||
* @method NotificationInterface getEnvelope()
|
||||
*/
|
||||
final class Flasher extends AbstractManager implements FlasherInterface
|
||||
{
|
||||
|
||||
@@ -3,7 +3,31 @@
|
||||
namespace Flasher\Prime;
|
||||
|
||||
use Flasher\Prime\Factory\FlasherFactoryInterface;
|
||||
use Flasher\Prime\Notification\NotificationBuilderInterface;
|
||||
use Flasher\Prime\Notification\NotificationInterface;
|
||||
use Flasher\Prime\Stamp\StampInterface;
|
||||
|
||||
/**
|
||||
* @method NotificationBuilderInterface type($type, $message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface message($message)
|
||||
* @method NotificationBuilderInterface options($options)
|
||||
* @method NotificationBuilderInterface setOption($name, $value)
|
||||
* @method NotificationBuilderInterface unsetOption($name)
|
||||
* @method NotificationBuilderInterface handler(string $handler)
|
||||
* @method NotificationBuilderInterface with(StampInterface[] $stamps)
|
||||
* @method NotificationBuilderInterface withStamp(StampInterface $stamp)
|
||||
* @method NotificationBuilderInterface priority($priority)
|
||||
* @method NotificationBuilderInterface hops($amount)
|
||||
* @method NotificationBuilderInterface keep()
|
||||
* @method NotificationBuilderInterface success($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface error($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface info($message = null, array $options = array())
|
||||
* @method NotificationBuilderInterface warning($message = null, array $options = array())
|
||||
* @method Envelope flash(StampInterface[] $stamps)
|
||||
* @method Envelope addFlash(string|Envelope $type, string $message = null, array $options = array())
|
||||
* @method NotificationInterface getNotification()
|
||||
* @method NotificationInterface getEnvelope()
|
||||
*/
|
||||
interface FlasherInterface
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -232,7 +232,7 @@ class NotificationBuilder implements NotificationBuilderInterface
|
||||
*
|
||||
* @return Envelope|mixed
|
||||
*/
|
||||
public function dispatch($stamps = array())
|
||||
public function flash($stamps = array())
|
||||
{
|
||||
if (!empty($stamps)) {
|
||||
$this->with($stamps);
|
||||
@@ -244,4 +244,22 @@ class NotificationBuilder implements NotificationBuilderInterface
|
||||
|
||||
return $this->eventDispatcher->dispatch($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @param array $options
|
||||
*
|
||||
* @return Envelope|mixed
|
||||
*/
|
||||
public function addFlash($type, $message, array $options = array())
|
||||
{
|
||||
if (is_string($type)) {
|
||||
$this->type($type, $message, $options);
|
||||
} elseif ($type instanceof NotificationInterface) {
|
||||
$this->envelope = Envelope::wrap($type);
|
||||
}
|
||||
|
||||
return $this->flash();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user