예제 #1
0
 /**
  *
  */
 protected function registerListeners()
 {
     EventFacade::listen('*', function ($param) {
         $this->data[] = ['name' => EventFacade::firing(), 'param' => $param, 'time' => microtime(true)];
         $this->stream();
     });
 }
 public function register()
 {
     foreach ($this->listening as $webookable) {
         $this->app['events']->listen($webookable, function ($event) use($webookable) {
             if (!Config::get("seeding")) {
                 $this->react(Event::firing(), $event);
             }
         });
     }
 }
 protected function registerEloquentEvents()
 {
     // Flush Elegant cache when anything changes for models registered by Elegant
     Event::listen('eloquent.*', function ($caller) {
         $callerClass = get_class($caller);
         if (!in_array($callerClass, ElegantConfig::getModelsAsClassNames())) {
             return;
         }
         if (in_array(Event::firing(), ['eloquent.saved', 'eloquent.deleted', 'eloquent.updated', 'eloquent.created']) && $this->cacheIsTaggable()) {
             Cache::tags('elegant-' . Support\ElegantModel::normalizeClassName($callerClass))->flush();
         }
     });
 }
예제 #4
0
 /**
  * EventsDataSource constructor.
  */
 public function __construct()
 {
     $this->events = [];
     Event::listen('*', function ($param) {
         /** @todo fix that shit */
         if (!class_exists('events')) {
             return;
         }
         $this->events[] = ['name' => Event::firing(), 'param' => json_encode($param), 'time' => microtime(true)];
         $currentTime = microtime(true);
         Clockwork::addEvent(uniqid('event_'), Event::firing(), $currentTime, $currentTime);
     });
 }
예제 #5
0
 public function testRun()
 {
     $dsn = 'ipc://test-run.ipc';
     if (!($pid = pcntl_fork())) {
         $listener = new EventListener(['bind' => $dsn]);
         Event::listen('request.event', function () use($listener) {
             $listener->socket()->push(Event::firing(), func_get_args());
             Event::fire('zeroevents.service.stop');
         });
         (new EventService())->listen($listener)->run();
         exit;
     }
     $listener = new EventListener(['connect' => $dsn]);
     Event::listen('request.event', $listener);
     Event::fire('request.event', ['source', 'parent']);
     $this->assertSame(['event' => 'request.event', 'payload' => ['source', 'parent'], 'address' => null], $listener->socket()->pull());
     pcntl_wait($status);
     posix_kill($pid, SIGKILL);
 }
 /**
  * Event listener.
  *
  * @param $eventData
  */
 public function handleEvent($eventData)
 {
     $eventName = Event::firing();
     $webhooks = $this->getWebhooks()->where("event", $eventName);
     $webhooks = $webhooks->filter($this->config->get("captain_hook.filter", null));
     $this->callWebhooks($webhooks, $eventData);
 }
 /**
  * Event listener.
  *
  * @param $eventData
  */
 public function handleEvent($eventData)
 {
     $eventName = Event::firing();
     $webhooks = $this->getWebhooks()->where('event', $eventName);
     $webhooks = $webhooks->filter($this->config->get('captain_hook.filter', null));
     if (!$webhooks->isEmpty()) {
         $this->dispatch(new TriggerWebhooksJob($webhooks, $eventData));
     }
 }
예제 #8
0
 public function testPullAndFire()
 {
     $dsn = 'ipc://test-pull-and-fire.ipc';
     if (!($pid = pcntl_fork())) {
         $socket = $this->socket();
         $socket->bind($dsn);
         $socket->push('response.event', [$socket->pull()]);
         exit;
     }
     $socket = $this->socket();
     $socket->connect($dsn)->push('request.event', ['source', 'parent']);
     $event = null;
     Event::listen('response.event', function () use(&$event) {
         $event = ['event' => Event::firing(), 'payload' => func_get_args()];
         return true;
     });
     $this->assertTrue($socket->pullAndFire());
     $this->assertSame(['event' => 'response.event', 'payload' => [['event' => 'request.event', 'payload' => ['source', 'parent'], 'address' => null]]], $event);
     posix_kill($pid, SIGKILL);
     @unlink('test-pull-and-fire.ipc');
 }
예제 #9
0
 /**
  * Log Esensi events to the info log.
  *
  * @return void
  */
 public function logEvent()
 {
     if (config('app.debug')) {
         Log::info(Event::firing());
     }
 }
예제 #10
0
 /**
  * Magic method for event dispatcher
  *
  * @return mixed
  */
 public function __invoke()
 {
     return $this->socket()->push(Event::firing(), func_get_args());
 }