Exemplo n.º 1
0
 public function listen(Dispatcher $events)
 {
     $events->subscribe('S12g\\ImageAttachments\\Listeners\\AddClientAssets');
     $events->listen(RegisterApiRoutes::class, function (RegisterApiRoutes $event) {
         $event->post('/s12g/image_attachments', 's12g.imageattachments.upload', 'S12g\\ImageAttachments\\UploadAction');
     });
 }
 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  */
 public function subscribe($events)
 {
     $events->listen(\App\Events\Frontend\Auth\UserLoggedIn::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onLoggedIn');
     $events->listen(\App\Events\Frontend\Auth\UserLoggedOut::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onLoggedOut');
     $events->listen(\App\Events\Frontend\Auth\UserRegistered::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onRegistered');
     $events->listen(\App\Events\Frontend\Auth\UserConfirmed::class, 'App\\Listeners\\Frontend\\Auth\\UserEventListener@onConfirmed');
 }
Exemplo n.º 3
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Events\Dispatcher $events
  * @return void
  */
 public function subscribe($events)
 {
     Recipe::observe('App\\Observers\\RecipeModelObserver');
     $events->listen('App\\Events\\Recipe\\RecipeCreated', 'App\\Listeners\\RecipeEventListener@onRecipeCreated');
     $events->listen('App\\Events\\Recipe\\RecipeUpdated', 'App\\Listeners\\RecipeEventListener@onRecipeUpdated');
     $events->listen('App\\Events\\Recipe\\RecipeDeleted', 'App\\Listeners\\RecipeEventListener@onRecipeDeleted');
 }
Exemplo n.º 4
0
 /**
  * Listen to the events.
  *
  * @param  \Illuminate\Events\Dispatcher  $dispatcher
  * @return void
  */
 public function subscribe(Dispatcher $dispatcher)
 {
     $dispatcher->listen('cartalyst.cart.added', __CLASS__ . '@onItemAdded');
     $dispatcher->listen('cartalyst.cart.updated', __CLASS__ . '@onItemUpdated');
     $dispatcher->listen('cartalyst.cart.removed', __CLASS__ . '@onItemRemoved');
     $dispatcher->listen('cartalyst.cart.cleared', __CLASS__ . '@onCartCleared');
 }
Exemplo n.º 5
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  $events
  * @return array
  */
 public function subscribe(Dispatcher $events)
 {
     $class = get_called_class();
     foreach ($this->getEvents() as $event) {
         $method = $this->getMethodName($event);
         if (!method_exists($this, $method)) {
             continue;
         }
         $events->listen($event, $class . '@' . $method);
     }
     // --- Alternative (später Benchmark machen und dann entscheiden ---
     //		$methods = $this->cache(md5($class.'events'), function(){
     //			return array_filter(get_class_methods($this), function($method){
     //				return preg_match("/^on/u", $method) ? $method : null;
     //			});
     //		});
     //
     //		// Get all Event Handling Methods
     //
     //		$qvents = $this->getQualifiedEvents();
     //
     //		foreach($methods as $method)
     //		{
     //			if ( ! array_key_exists($method, $qvents) ) continue;
     //
     //			$events->listen($qvents[$method], $class . '@' . $method);
     //		}
     // --- Second Alternative ---
     //		foreach( $this->getQualifiedEvents() as $method => $event )
     //		{
     //			if ( ! method_exists($this, $method) ) continue;
     //
     //			$events->listen($event, $class . '@' . $method);
     //		}
 }
Exemplo n.º 6
0
 public function postInstall(Request $request, Installer $installer, Dispatcher $dispatcher)
 {
     $output = new BufferedOutput();
     $installer->setFieldValues($request->all());
     $versions = $installer->getVersions();
     foreach ($versions as $version) {
         $tasks = $installer->getTasksForVersion($version);
         foreach ($tasks as $task) {
             $output->writeln('<span class="text-info">Running ' . $task->getTitle() . ' Task...</span>');
             try {
                 $task->setInput($installer->getFieldValues());
                 $task->run($output);
             } catch (TaskRunException $e) {
                 $output->writeln('<span class="text-danger">' . $e->getMessage() . '</span>');
                 return new JsonResponse(['output' => $output, 'status' => 'error'], 200);
             }
             $output->writeln('<span class="text-info">Task ' . $task->getTitle() . ' Completed!</span>');
         }
     }
     $dispatcher->fire(new AfterInstallEvent($installer, $output));
     $installer->saveCompleted();
     $output->writeln('<span class="text-success">Installation Completed!</span>');
     $output = array_filter(explode("\n", $output->fetch()));
     return new JsonResponse(['output' => $output, 'status' => 'success'], 200);
 }
Exemplo n.º 7
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  * @return array
  */
 public function subscribe($events)
 {
     $events->listen('auth.logout', 'App\\Handlers\\Events\\CartHandler@customer_logout');
     $events->listen('auth.login', 'App\\Handlers\\Events\\CartHandler@customer_login');
     $events->listen('App\\Events\\Cart\\Shipment\\CollectMethods', 'App\\Handlers\\Events\\CartHandler@shipment_methods');
     $events->listen('App\\Events\\Cart\\Payment\\CollectMethods', 'App\\Handlers\\Events\\CartHandler@payment_methods');
 }
Exemplo n.º 8
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Events\Dispatcher $events
  * @return void
  */
 public function subscribe($events)
 {
     Ingredient::observe('App\\Observers\\IngredientModelObserver');
     $events->listen('App\\Events\\Ingredient\\IngredientCreated', 'App\\Listeners\\IngredientEventListener@onIngredientCreated');
     $events->listen('App\\Events\\Ingredient\\IngredientUpdated', 'App\\Listeners\\IngredientEventListener@onIngredientUpdated');
     $events->listen('App\\Events\\Ingredient\\IngredientDeleted', 'App\\Listeners\\IngredientEventListener@onIngredientDeleted');
 }
Exemplo n.º 9
0
 /**
  * Send Laravel's Session Id to server via ZMQ
  * before client's websocket connection
  * 
  * @return void
  */
 public function sync($message)
 {
     $socket = $this->getSocket();
     $message = json_encode($message);
     // Fire events
     $this->events->fire('sid.sync', [$socket, $message]);
 }
Exemplo n.º 10
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher $events
  */
 public function subscribe($events)
 {
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserCreatedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserCreatedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserUpdatedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserUpdatedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\UserDeletedEvent', 'cms\\App\\Listeners\\UsersEventsListener@handleUserDeletedEvent');
     $events->listen('cms\\Domain\\Users\\Users\\Events\\NewUserRegisteredEvent', 'cms\\App\\Listeners\\UsersEventsListener@newUserRegisteredEvent');
 }
 /**
  * Handle the command.
  *
  * @param InviteModel $invites
  * @param Request $request
  * @param Dispatcher $events
  * @return array
  */
 public function handle(InviteModel $invites, Request $request, Dispatcher $events)
 {
     $user['ip_address'] = $request->ip();
     // Slack configurations
     $slackTeam = config('anomaly.extension.slack_inviter::slack.team');
     $slackToken = config('anomaly.extension.slack_inviter::slack.token');
     $slackChannels = config('anomaly.extension.slack_inviter::slack.channels');
     if (!$slackToken) {
         throw new \Exception("Slack API has not been configured. Missing 'anomaly.extension.slack_inviter::slack.auth_token'");
     }
     $slackInviteUrl = 'https://' . $slackTeam . '.slack.com/api/users.admin.invite?t=' . time();
     $fields = array('email' => $user['email'] = $this->builder->getFormValue('email'), 'first_name' => urlencode($user['name'] = $this->builder->getFormValue('name')), 'channels' => $slackChannels, 'token' => $slackToken, 'set_active' => true, '_attempts' => '1');
     // Open the connection.
     $ch = curl_init();
     // set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $slackInviteUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
     // Execute the request.
     $reply = json_decode(curl_exec($ch), true);
     if ($reply['ok'] == false) {
         $user['error'] = $reply['error'];
     } else {
         $user['successful'] = true;
     }
     // Close the connection.
     curl_close($ch);
     $events->fire(new SlackInviteWasSent($invites->create($user)));
     return $reply;
 }
Exemplo n.º 12
0
 /**
  * @param $route
  * @param $request
  * @param null $scope
  * @return null|BridgeResponse
  */
 public function filter($route, $request, $scope = null)
 {
     $beforeAccessResult = $this->dispatcher->until('oauth.access.before', array($scope));
     if ($beforeAccessResult) {
         return null;
     }
     /** @var BridgeRequest $bridgeRequest */
     $bridgeRequest = BridgeRequest::createFromRequest($request);
     $bridgeResponse = new BridgeResponse();
     $resController = $this->server->getResourceController();
     if (!$resController->verifyResourceRequest($bridgeRequest, $bridgeResponse, $scope)) {
         $this->dispatcher->fire('oauth.access.failed');
         return $bridgeResponse;
     }
     $token = $resController->getAccessTokenData($bridgeRequest, $bridgeResponse);
     $client = $this->clientRepo->find($token['client_id']);
     $tokenScope = $token['scope'];
     $user = null;
     if (isset($token['user_id'])) {
         $user = $this->userProvider->retrieveById($token['user_id']);
     }
     if ($tokenScope) {
         $tokenScope = explode(' ', $tokenScope);
     }
     $eventPayload = array($client, $user, $tokenScope);
     $this->dispatcher->fire('oauth.access.valid', $eventPayload);
 }
Exemplo n.º 13
0
 /**
  * @param CommentForm  $commentForm
  * @param Dispatcher   $events
  */
 public function __construct(CommentForm $commentForm, Dispatcher $events)
 {
     $this->beforeFilter('auth', ['only' => ['update', 'trash', 'approve']]);
     $this->commentForm = $commentForm;
     $events->subscribe('FIIP\\Comments\\CommentEventHandler');
     Comments::setDispatcher($events);
 }
Exemplo n.º 14
0
 function __construct()
 {
     parent::__construct();
     // Get CI instance to obtain DB settings
     $ci =& get_instance();
     $this->addConnection(array('driver' => 'mysql', 'host' => $ci->db->hostname, 'database' => $ci->db->database, 'username' => $ci->db->username, 'password' => $ci->db->password, 'charset' => $ci->db->char_set, 'collation' => $ci->db->dbcollat, 'prefix' => $ci->db->dbprefix));
     // Listen to Model related events (saving, saved, updating, updated, creating, created etc).
     $this->setEventDispatcher(new Dispatcher(new Container()));
     // For CI Profiler (debugging utility)
     $events = new Dispatcher();
     $events->listen('illuminate.query', function ($query, $bindings, $time, $name) {
         // Format binding data for sql insertion
         foreach ($bindings as $i => $binding) {
             if ($binding instanceof \DateTime) {
                 $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
             } else {
                 if (is_string($binding)) {
                     $bindings[$i] = "'{$binding}'";
                 }
             }
         }
         // Insert bindings into query
         $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
         $query = vsprintf($query, $bindings);
         // Add it into CodeIgniter
         $ci =& get_instance();
         $ci->db->query_times[] = $time;
         $ci->db->queries[] = $query;
     });
     $this->setEventDispatcher($events);
     $this->setAsGlobal();
     $this->bootEloquent();
 }
Exemplo n.º 15
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  \Illuminate\Events\Dispatcher  $events
  * @return array
  */
 public function subscribe($events)
 {
     $events->listen('App\\Form\\Customer\\Register', 'App\\Handlers\\Forms\\Customer\\AuthHandler@register', 10);
     $events->listen('App\\Form\\Customer\\Login', 'App\\Handlers\\Forms\\Customer\\AuthHandler@login', 10);
     $events->listen('App\\Form\\Customer\\ForgotPassword', 'App\\Handlers\\Forms\\Customer\\AuthHandler@forgot_password', 10);
     $events->listen('App\\Form\\Customer\\ResetPassword', 'App\\Handlers\\Forms\\Customer\\AuthHandler@reset_password', 10);
 }
 /**
  * Dispatches the array of events, firing off the appropriate event name for each and logging the event fired.
  *
  * @param array $events
  */
 public function dispatch(array $events)
 {
     foreach ($events as $event) {
         $eventName = $this->getEventName($event);
         $this->log->info("New event [{$eventName}]", get_object_vars($event));
         $this->event->fire($eventName, $event);
     }
 }
 /**
  * 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>";
         });
     }
 }
Exemplo n.º 18
0
 /**
  * @param array $events
  */
 public function dispatch(array $events)
 {
     foreach ($events as $event) {
         $eventName = $this->getEventName($event);
         $this->event->fire($eventName, $event);
         $this->log->info("{$eventName} was fired.");
     }
 }
Exemplo n.º 19
0
 /**
  * Event subscribe handler.
  *
  * @throws \Exception
  */
 public function subscribe()
 {
     $method = 'handle';
     if (method_exists($this, $getHandler = 'get' . Str::ucfirst($method) . 'r')) {
         $method = $this->{$getHandler}();
     }
     $this->events->listen($this->getEvent(), [$this, $method]);
 }
 /**
  * Register the listeners for the subscriber.
  *
  * @param  Illuminate\Events\Dispatcher  $events
  */
 public function subscribe(\Illuminate\Events\Dispatcher $events)
 {
     $class = 'Nasqueron\\Notifications\\Listeners\\NotificationListener';
     $events->listen('Nasqueron\\Notifications\\Events\\DockerHubPayloadEvent', "{$class}@onDockerHubPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\GitHubPayloadEvent', "{$class}@onGitHubPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\JenkinsPayloadEvent', "{$class}@onJenkinsPayload");
     $events->listen('Nasqueron\\Notifications\\Events\\PhabricatorPayloadEvent', "{$class}@onPhabricatorPayload");
 }
Exemplo n.º 21
0
 /**
  * @param string $class
  * @param \Illuminate\Events\Dispatcher $events
  */
 protected function addHandlers(string $class, Dispatcher $events)
 {
     $baseName = class_basename($class);
     $created = 'eloquent.created: ' . $class;
     $events->listen($created, self::class . '@on' . $baseName . 'Create');
     $updated = 'eloquent.updated: ' . $class;
     $events->listen($updated, self::class . '@on' . $baseName . 'Edit');
 }
Exemplo n.º 22
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  Dispatcher $events
  */
 public function subscribe($events)
 {
     if (config('login-activity.track_login', false)) {
         $events->listen(\Illuminate\Auth\Events\Login::class, 'Aginev\\LoginActivity\\LoginActivityListener@onUserLogin');
     }
     if (config('login-activity.track_logout', false)) {
         $events->listen(\Illuminate\Auth\Events\Logout::class, 'Aginev\\LoginActivity\\LoginActivityListener@onUserLogout');
     }
 }
Exemplo n.º 23
0
 /**
  * Transfer local images to cloud storage.
  */
 public function transferLocalImages()
 {
     $this->imageResource->orWhere(function (Builder $query) {
         $query->where('filename', '!=', '');
         $query->whereNotNull('filename');
     })->get()->each(function (Image $image) {
         $this->dispatcher->fire(new NewImageEvent($image));
     });
 }
Exemplo n.º 24
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param \Illuminate\Events\Dispatcher $events
  *
  * @return void
  */
 public function subscribe(Dispatcher $events)
 {
     $events->listen('navigation.main', 'App\\Subscribers\\NavigationSubscriber@onNavigationMainFirst', 8);
     $events->listen('navigation.main', 'App\\Subscribers\\NavigationSubscriber@onNavigationMainSecond', 5);
     $events->listen('navigation.main', 'App\\Subscribers\\NavigationSubscriber@onNavigationMainThird', 2);
     $events->listen('navigation.bar', 'App\\Subscribers\\NavigationSubscriber@onNavigationBarFirst', 8);
     $events->listen('navigation.bar', 'App\\Subscribers\\NavigationSubscriber@onNavigationBarSecond', 5);
     $events->listen('navigation.bar', 'App\\Subscribers\\NavigationSubscriber@onNavigationBarThird', 2);
 }
function subscribe(Dispatcher $events)
{
    $events->listen(ConfigureFormatter::class, function (ConfigureFormatter $event) {
        $event->configurator->MediaEmbed->add('bilibili', ['host' => 'www.bilibili.com', 'extract' => "!www.bilibili.com/video/av(?'id'[0-9]+)/!", 'flash' => ['width' => 544, 'height' => 415, 'src' => 'https://static-s.bilibili.com/miniloader.swf?aid={@id}']]);
        $event->configurator->MediaEmbed->add('music163', ['host' => 'music.163.com', 'extract' => "!music\\.163\\.com/#/song\\?id=(?'id'\\d+)!", 'iframe' => ['width' => 330, 'height' => 86, 'frameborder' => 'no', 'border' => '0', 'marginwidth' => '0', 'marginheight' => '0', 'src' => 'http://music.163.com/outchain/player?type=2&id={@id}&auto=0&height=66']]);
        $event->configurator->MediaEmbed->add('applemusicplaylist', ['host' => 'itunes.apple.com', 'extract' => "!itunes\\.apple\\.com/(?'country'[a-z]+)/playlist/[a-z-a-z]+/idpl.(?'id'[0-9a-z]+)!", 'iframe' => ['width' => '100%', 'height' => 500, 'src' => 'https://playlists.applemusic.com/embed/pl.{@id}?country={@country}&app=music']]);
        (new MediaPack())->configure($event->configurator);
    });
}
Exemplo n.º 26
0
 protected function addPageTypeLeaveSubscription(LaravelDispatcher $dispatcher)
 {
     $dispatcher->listen('sitetree.page-type-leaving', function ($page, $oldPageTypeId) {
         if (!($plugin = $this->getFormPlugin($oldPageTypeId))) {
             return;
         }
         $plugin->processPageTypeLeave($page, $oldPageTypeId);
     });
 }
Exemplo n.º 27
0
 /**
  * Register the listeners for the subscriber.
  *
  * @param  Illuminate\Events\Dispatcher  $events
  */
 public function subscribe(\Illuminate\Events\Dispatcher $events)
 {
     $ns = 'Nasqueron\\Notifications\\Events';
     $class = 'Nasqueron\\Notifications\\Listeners\\LastPayloadSaver';
     $eventsToListen = ['DockerHubPayloadEvent', 'GitHubPayloadEvent', 'JenkinsPayloadEvent', 'PhabricatorPayloadEvent'];
     foreach ($eventsToListen as $event) {
         $events->listen("{$ns}\\{$event}", "{$class}@onPayload");
     }
 }
 function filter($route, $request)
 {
     $payload = $request->header('X-Auth-Token');
     $user = $this->driver->validate($payload);
     if (!$user) {
         throw new NotAuthorizedException();
     }
     $this->events->fire('auth.token.valid', $user);
 }
Exemplo n.º 29
0
 public function subscribe(Dispatcher $events)
 {
     if (defined('FLARUM_TENANT')) {
         $events->listen(ConfigureClientView::class, [$this, 'setFilename']);
         Application::booting(function ($app) {
             $app->make('config')->set('cache.prefix', FLARUM_TENANT);
         });
     }
 }
Exemplo n.º 30
0
function subscribe(Dispatcher $events)
{
    $events->listen(ConfigureFormatter::class, function (ConfigureFormatter $event) {
        $event->configurator->Autoimage;
        $event->configurator->MediaEmbed->add('music163', ['host' => 'music.163.com', 'extract' => "!music\\.163\\.com/#/song\\?id=(?'id'\\d+)!", 'iframe' => ['width' => 450, 'height' => 86, 'src' => '//music.163.com/outchain/player?type=2&id={@id}&auto=0&height=66']]);
        $event->configurator->MediaEmbed->add('bilibili', ['host' => 'www.bilibili.com', 'extract' => ["!www.bilibili.com/video/av(?'id'\\d+)/!", "!www.bilibili.com/mobile/video/av(?'id'\\d+)\\.html!"], 'flash' => ['width' => 760, 'height' => 450, 'src' => 'https://static-s.bilibili.com/miniloader.swf?aid={@id}']]);
        $event->configurator->MediaEmbed->add('qq', ['host' => 'qq.com', 'extract' => ["!qq\\.com/x/cover/\\w+/(?'id'\\w+)\\.html!", "!qq\\.com/x/cover/\\w+\\.html\\?vid=(?'id'\\w+)!", "!qq\\.com/cover/[^/]+/\\w+/(?'id'\\w+)\\.html!", "!qq\\.com/cover/[^/]+/\\w+\\.html\\?vid=(?'id'\\w+)!", "!qq\\.com/x/page/(?'id'\\w+)\\.html!", "!qq\\.com/page/[^/]+/[^/]+/[^/]+/(?'id'\\w+)\\.html!"], 'iframe' => ['width' => 760, 'height' => 450, 'src' => '//v.qq.com/iframe/player.html?vid={@id}&tiny=0&auto=0']]);
        (new MediaPack())->configure($event->configurator);
    });
}