/**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(ConfigurePostTypes::class, [$this, 'addPostType']);
     $events->listen(ConfigureNotificationTypes::class, [$this, 'addNotificationType']);
     $events->listen(DiscussionWasLocked::class, [$this, 'whenDiscussionWasLocked']);
     $events->listen(DiscussionWasUnlocked::class, [$this, 'whenDiscussionWasUnlocked']);
 }
 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']);
     $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
     $events->listen(ConfigureApiController::class, [$this, 'includeRelationships']);
     $events->listen(PrepareApiData::class, [$this, 'filterVisiblePosts']);
 }
Example #3
0
 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
     $events->listen(PrepareApiData::class, [$this, 'loadTagsRelationship']);
     $events->listen(ConfigureApiController::class, [$this, 'includeTagsRelationship']);
     $events->listen(PrepareApiAttributes::class, [$this, 'prepareApiAttributes']);
 }
 public function subscribe(Dispatcher $events)
 {
     $events->listen(RegisterPostTypes::class, [$this, 'registerPostType']);
     $events->listen(RegisterNotificationTypes::class, [$this, 'registerNotificationType']);
     $events->listen(DiscussionWasStickied::class, [$this, 'whenDiscussionWasStickied']);
     $events->listen(DiscussionWasUnstickied::class, [$this, 'whenDiscussionWasUnstickied']);
 }
 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
     $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
     $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
     $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
 }
Example #6
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  Dispatcher $events
  *
  * @return array
  */
 public function subscribe($events)
 {
     $events->listen(ServicePreProcess::class, static::class . '@onServicePreProcess');
     $events->listen(ServicePostProcess::class, static::class . '@onServicePostProcess');
     $events->listen(ResourcePreProcess::class, static::class . '@onResourcePreProcess');
     $events->listen(ResourcePostProcess::class, static::class . '@onResourcePostProcess');
 }
 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen('Flarum\\Core\\Events\\PostWasPosted', __CLASS__ . '@whenPostWasPosted');
     $events->listen('Flarum\\Core\\Events\\PostWasDeleted', __CLASS__ . '@whenPostWasDeleted');
     $events->listen('Flarum\\Core\\Events\\PostWasHidden', __CLASS__ . '@whenPostWasHidden');
     $events->listen('Flarum\\Core\\Events\\PostWasRestored', __CLASS__ . '@whenPostWasRestored');
 }
Example #8
0
 /**
  * Register an event for the dispatcher to listen for.
  *
  * @param  string   $name
  * @param  Closure  $callback
  * @return void
  */
 protected function registerEvent($name, Closure $callback)
 {
     if (!isset(static::$dispatcher)) {
         $this->initEventDispatcher();
     }
     static::$dispatcher->listen($name, $callback);
 }
 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(GetModelRelationship::class, [$this, 'getModelRelationship']);
     $events->listen(PostWasDeleted::class, [$this, 'postWasDeleted']);
     $events->listen(GetApiRelationship::class, [$this, 'getApiRelationship']);
     $events->listen(ConfigureApiController::class, [$this, 'includeFlagsRelationship']);
     $events->listen(PrepareApiData::class, [$this, 'prepareApiData']);
 }
Example #10
0
 public function boot(DispatcherContract $events)
 {
     $this->registerMaxFolderSizeValidator();
     $this->mergeConfigFrom(__DIR__ . '/../Config/config.php', 'asgard.media.config');
     $this->publishes([__DIR__ . '/../Config/config.php' => config_path('asgard.media.config' . '.php')], 'config');
     $events->listen('*', HandleMediaStorage::class);
     $events->listen('*', RemovePolymorphicLink::class);
 }
Example #11
0
 public function admin($uri, $action)
 {
     $route = $this->addRoute('admin', $uri, $action);
     $this->actions->listen('admin_menu', function () use($uri, $route) {
         $this->addAdminMenuPage($uri, $route);
     });
     return $route;
 }
 /**
  * Bind the given JavaScript to the view.
  *
  * @param string $js
  */
 public function bind($js)
 {
     foreach ($this->views as $view) {
         $this->event->listen("composing: {$view}", function () use($js) {
             echo "<script>{$js}</script>";
         });
     }
 }
 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  *
  * @return void
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen('command.publishvendors', __CLASS__ . '@onPublishVendors', 5);
     $events->listen('command.resetmigrations', __CLASS__ . '@onResetMigrations', 5);
     $events->listen('command.runmigrations', __CLASS__ . '@onRunMigrations', 5);
     $events->listen('command.runseeding', __CLASS__ . '@onRunSeeding', 5);
     $events->listen('command.updatecache', __CLASS__ . '@onUpdateCache', 5);
 }
Example #14
0
 /**
  * Register an event with the dispatcher.
  *
  * @param  string  $event
  * @param  \Closure|string  $callback
  *
  * @return void
  */
 protected static function registerObservableEvent($event, $callback)
 {
     if (!isset(static::$dispatcher)) {
         return;
     }
     $className = get_called_class();
     $event = with(new static())->getObservableKey($event);
     static::$dispatcher->listen("{$event}: {$className}", $callback);
 }
Example #15
0
 public function subscribe(Dispatcher $events)
 {
     $events->listen(RegisterNotificationTypes::class, [$this, 'addNotificationType']);
     // Register with '1' as priority so this runs before discussion metadata
     // is updated, as we need to compare the user's last read number to that
     // of the previous post.
     $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted'], 1);
     $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
     $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
     $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
 }
 /** @test */
 public function it_trigger_an_handler_using_native_laravel_dispatcher()
 {
     $testListener = [NotifyEvent::class => [NotifyUserTest::class]];
     // Listen for events as the laravel way
     foreach ($testListener as $event => $listeners) {
         foreach ($listeners as $listener) {
             $this->laravelDispatcher->listen($event, $listener);
         }
     }
     $notification = $this->laravelDispatcher->fire(new NotifyEvent(new NotifynderEvent('userActivated')));
     $this->assertEquals('hello', $notification[0]->url);
 }
Example #17
0
 /**
  * @param Dispatcher $events
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
     $events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
     $events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
     $events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
     $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']);
     $events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']);
     $events->listen(PostWasLiked::class, [$this, 'whenPostWasLiked']);
     $events->listen(PostWasUnLiked::class, [$this, 'whenPostWasUnLiked']);
     $events->listen(PostWasBest::class, [$this, 'whenPostWasBest']);
     $events->listen(PostWasUnbest::class, [$this, 'whenPostWasUnbest']);
 }
 /**
  * Perform post-registration booting of services.
  *
  * @return void
  */
 public function boot(Kernel $kernel, DispatcherContract $events, Router $router)
 {
     $this->mergeConfigFrom(__DIR__ . '/config/usermanager.php', 'kiwi.usermanager');
     $this->loadViewsFrom(__DIR__ . '/resources/views', 'kiwi/usermanager');
     $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'kiwi/usermanager');
     $this->publishes([__DIR__ . '/resources/views' => base_path('resources/views/vendor/kiwi/usermanager'), __DIR__ . '/resources/lang' => base_path('resources/lang/vendor/kiwi/usermanager'), __DIR__ . '/config/usermanager.php' => config_path('kiwi/usermanager.php')]);
     // Set e-mail reset view
     Config::set('auth.password.email', 'kiwi/usermanager::emails.' . $this->app->getLocale() . '.reset');
     // Add package routes
     $this->app->router->group(['namespace' => 'Kiwi\\UserManager\\Http\\Controllers'], function () {
         require __DIR__ . '/Http/routes.php';
     });
     /**
      *   Register events
      */
     $registeredEvents = Config::get('kiwi.usermanager.events');
     foreach ($registeredEvents as $event => $listeners) {
         if (is_array($listeners)) {
             foreach ($listeners as $listener) {
                 $events->listen($event, $listener);
             }
         } elseif (is_string($listeners)) {
             $events->listen($event, $listeners);
         } else {
             throw new UserManagerException('Invalid listeners for ' . $event . ' event (string or array required, ' . gettype($listeners) . ' provided)');
         }
     }
     /*
      *   Add password validator
      *   Checks if $value matches current user's password
      */
     Validator::extend('password', 'Kiwi\\UserManager\\Validators\\Password@validate', trans('kiwi/usermanager::validation.password'));
     /*
      *   Init services
      */
     $kernel->pushMiddleware('Kiwi\\UserManager\\Http\\Middleware\\UserManager');
     /*
      * NoCaptcha config
      */
     $noCaptcha = Config::get('kiwi.usermanager.services.nocaptcha');
     if (!is_null($noCaptcha) && $noCaptcha) {
         $noCaptchaSecretKey = env('NOCAPTCHA_SECRET');
         $noCaptchaSiteKey = env('NOCAPTCHA_SITEKEY');
         if (strlen($noCaptchaSecretKey) == 0 || strlen($noCaptchaSiteKey) == 0) {
             throw new UserManagerException('In order to use NoCaptcha ReCaptcha service, please set your secret keys in your env file (NOCAPTCHA_SITEKEY, NOCAPTCHA_SECRET)');
         }
     }
 }
Example #19
0
 public function subscribe(Dispatcher $events)
 {
     $events->listen(FrontUserRegistered::class, function (FrontUserRegistered $event) {
         Mail::send(new Welcome($event->user));
     });
     $events->listen(FrontUserCreatedThroughBack::class, function (FrontUserCreatedThroughBack $event) {
         Password::broker('front')->sendResetLink(['email' => $event->user->email], function (Message $message) {
             $message->subject('Welkom bij ' . config('app.url'));
         });
     });
     $events->listen(BackUserCreated::class, function (BackUserCreated $event) {
         Password::broker('back')->sendResetLink(['email' => $event->user->email], function (Message $message) {
             $message->subject('Welkom bij ' . config('app.url'));
         });
     });
 }
 /**
  * setting up listener
  *
  * @param Dispatcher $events
  * @param Writer $log
  */
 private function setupListener(Dispatcher $events, Writer $log)
 {
     $environments = config('slow-query-logger.environments', []);
     if (!$this->app->environment($environments)) {
         return;
     }
     $events->listen(QueryExecuted::class, function (QueryExecuted $queryExecuted) use($log) {
         $sql = $queryExecuted->sql;
         $bindings = $queryExecuted->bindings;
         $time = $queryExecuted->time;
         $logSqlQueriesSlowerThan = config('slow-query-logger.time-to-log');
         if ($logSqlQueriesSlowerThan < 0 || $time < $logSqlQueriesSlowerThan) {
             return;
         }
         $level = config('slow-query-logger.log-level', 'debug');
         try {
             foreach ($bindings as $val) {
                 $sql = preg_replace('/\\?/', "'{$val}'", $sql, 1);
             }
             $log->log($level, $time . '  ' . $sql);
         } catch (\Exception $e) {
             //  be quiet on error
         }
     });
 }
 /**
  * Register any other events for your application.
  *
  * @param  DispatcherContract $events
  *
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     foreach ($this->listens() as $event => $listeners) {
         foreach ($listeners as $priority => $listener) {
             $events->listen($event, $listener, $priority);
         }
     }
     $events->listen('config.loaded', function () {
         BehaviorManager::init();
     });
     app('view')->addNamespace('layouts', layouts_path());
     $events->listen('view.page.edit', function ($page) {
         WYSIWYG::loadAllEditors();
         echo view('pages::parts.list')->with('page', $page);
     }, 999);
 }
 public static function registerMenu(Dispatcher $events, Repository $config)
 {
     $events->listen(BuildingMenu::class, function (BuildingMenu $event) use($config) {
         $menu = $config->get('adminlte.menu');
         call_user_func_array([$event->menu, 'add'], $menu);
     });
 }
Example #23
0
 /**
  * Register entity event handler.
  *
  * @param string $id
  * @param string $event
  * @param mixed $callback
  *
  * @return void
  */
 public static function registerEvent($id, $event, $callback)
 {
     if (!static::$dispatcher) {
         return;
     }
     static::$dispatcher->listen("entity.{$event}: {$id}", $callback);
 }
 /**
  * Register a model event with the dispatcher.
  *
  * @param  string  $event
  * @param  \Closure|string  $callback
  * @param  int  $priority
  * @return void
  */
 protected static function registerModelEvent($event, $callback, $priority = 0)
 {
     if (isset(static::$dispatcher)) {
         $name = get_called_class();
         static::$dispatcher->listen("eloquent.{$event}: {$name}", $callback, $priority);
     }
 }
Example #25
0
 /**
  * Register a model event with the dispatcher.
  *
  * @param  string          $event
  * @param  \Closure|string $callback
  * @param  int             $priority
  *
  * @return void
  */
 protected static function registerEvent($event, $callback, $priority = 0)
 {
     if (isset(static::$dispatcher)) {
         $name = get_called_class();
         static::$dispatcher->listen("portonefive.meta-bag.{$event}: {$name}", $callback, $priority);
     }
 }
Example #26
0
 /**
  * Register event listeners that will be fired regardless the type
  * of the entity.
  *
  * @param  string $event
  * @param  closure|string $callback
  * @return void
  */
 public function registerGlobalEvent($event, $callback)
 {
     if (!in_array($event, $this->events)) {
         throw new \Exception("Analogue : Event {$event} doesn't exist");
     }
     $this->eventDispatcher->listen("analogue.{$event}.*", $callback);
 }
Example #27
0
 public function __construct($options = [], Application $app = null, RepositoryContract $config = null, Dispatcher $dispatcher = null)
 {
     static::$options = $config !== null ? array_merge($options, $config->get('tracy')) : $options;
     TracyDebugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true));
     TracyDebugger::$maxDepth = array_get(static::$options, 'maxDepth');
     TracyDebugger::$maxLen = array_get(static::$options, 'maxLen');
     TracyDebugger::$showLocation = array_get(static::$options, 'showLocation');
     TracyDebugger::$strictMode = array_get(static::$options, 'strictMode');
     TracyDebugger::$editor = array_get(static::$options, 'editor');
     $bar = TracyDebugger::getBar();
     foreach (array_get(static::$options, 'panels') as $key => $enabled) {
         if ($enabled === true) {
             $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel';
             if (class_exists($class) === false) {
                 $class = $key;
             }
             $this->panels[$key] = new $class($app, static::$options);
             $bar->addPanel($this->panels[$key], $class);
         }
     }
     if ($dispatcher !== null) {
         $dispatcher->listen('kernel.handled', function ($request, $response) {
             return static::appendDebugbar($request, $response);
         });
     } else {
         TracyDebugger::enable();
     }
 }
Example #28
0
 /**
  * Register a new callback handler for when a log event is triggered.
  *
  * @param \Closure $callback        	
  * @return void
  *
  * @throws \RuntimeException
  */
 public function listen(Closure $callback)
 {
     if (!isset($this->dispatcher)) {
         throw new RuntimeException('Events dispatcher has not been set.');
     }
     $this->dispatcher->listen('illuminate.log', $callback);
 }
 /**
  * Setup the events.
  *
  * @param \Illuminate\Contracts\Events\Dispatcher $events
  * @param array                                   $config
  *
  * @return void
  */
 protected function setupEvents(Dispatcher $events, array $config)
 {
     if (isset($config['query']) && !$config['query']) {
         return;
     }
     $show = isset($config['bindings']) && $config['bindings'];
     if (class_exists(QueryExecuted::class)) {
         $events->listen(QueryExecuted::class, function (QueryExecuted $query) use($show) {
             $this->app->bugsnag->leaveBreadcrumb('Query executed', Breadcrumb::PROCESS_TYPE, $this->formatQuery($query->sql, $show ? $query->bindings : [], $query->time, $query->connectionName));
         });
     } else {
         $events->listen('illuminate.query', function ($sql, array $bindings, $time, $connection) use($show) {
             $this->app->bugsnag->leaveBreadcrumb('Query executed', Breadcrumb::PROCESS_TYPE, $this->formatQuery($sql, $show ? $bindings : [], $time, $connection));
         });
     }
 }
 /**
  * @param DispatcherContract $events
  */
 public function boot(DispatcherContract $events)
 {
     if (false === config('slack.endpoint', false)) {
         return;
     }
     $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'slack');
     /**
      * To get the actual changes we need to record the
      * changes before the Cachet event is fired.
      */
     Incident::updating(function (Incident $incident) {
         $dirty = [];
         foreach ($incident->getDirty() as $key => $v) {
             $dirty[$key] = $incident->getOriginal($key);
         }
         self::registerChanges('incident', $dirty);
     });
     Component::updating(function (Component $component) {
         $dirty = [];
         foreach ($component->getDirty() as $key => $v) {
             $dirty[$key] = $component->getOriginal($key);
         }
         self::registerChanges('component', $dirty);
     });
     /**
      * Send Slack notification on new incidents.
      */
     $events->listen('CachetHQ\\Cachet\\Bus\\Events\\Incident\\IncidentWasReportedEvent', function (IncidentWasReportedEvent $event) {
         $handler = new IncidentWasReportedHandler($event->incident->status, $event->incident->name, $event->incident->message, $event->incident['component_id']);
         return $handler->send();
     });
     /**
      * Send Slack notification on incident updates.
      */
     $events->listen('CachetHQ\\Cachet\\Bus\\Events\\Incident\\IncidentWasUpdatedEvent', function (IncidentWasUpdatedEvent $event) {
         $handler = new IncidentWasUpdatedHandler($event->incident->id, $event->incident->status, $event->incident->name, $event->incident->message, $event->incident['component_id'], self::getChanges('incident'));
         return $handler->send();
     });
     /**
      * Send Slack notification on component updates.
      * Note these are not send when a component is updated as part of an incident update.
      */
     $events->listen('CachetHQ\\Cachet\\Bus\\Events\\Component\\ComponentWasUpdatedEvent', function (ComponentWasUpdatedEvent $event) {
         $handler = new ComponentWasUpdatedHandler($event->component->status, $event->component->name);
         return $handler->send();
     });
 }