dev-master
9999999-devPHP notifier based on Symfony EventDispatcher. Sends notification(s) when events are fired. Provides file storage to keep tracks of notifications.
MIT
The Requires
by William Garcia
dispatcher event notification store
PHP notifier based on Symfony EventDispatcher. Sends notification(s) when events are fired. Provides file storage to keep tracks of notifications.
PHP notifier based on Symfony EventDispatcher., (*1)
$ composer install --dev
Store registration:, (*2)
use wooshell\storeNotifier\StoreNotifier; $myStoreDir = '/tmp/myStoreDir'; $myStore = 'cars'; $myStoreEntry = 'Smart Hayabusa'; $storeNotifier = new StoreNotifier($myStoreDir); $storeNotifier->store($myStore); $storeNotifier->store(...); $store->log($myStoreEntry);
Store notification:, (*3)
if (false === $store->exists($myStore, $myStoreEntry)) { $summary = '...'; $body = '...'; $store->send($summary, $body); }
Store locking:, (*4)
$lockFilepath = '/tmp/storeNotifier.lock'; $store->lock($lockFilepath ); ... $store->unlock($lockFilepath );
Create a listener:, (*5)
use Symfony\Component\EventDispatcher\Event; use wooshell\storeNotifier\EventDispatcher\Events\SendEvent; use wooshell\storeNotifier\EventDispatcher\Listeners\ListenerInterface; class EchoListener implements ListenerInterface { /** * @param Event $event */ public function send(Event $event) { /** @var SendEvent $event */ echo($event->getSummary(), $event->getBody())); } }
Add a listener into the store notifier:, (*6)
$store->getDispatcher()->addListener(SendEvent::EVENT_SEND, array(new EchoListener() , 'send'));
PHP notifier based on Symfony EventDispatcher. Sends notification(s) when events are fired. Provides file storage to keep tracks of notifications.
MIT
dispatcher event notification store