/** * @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); }
/** * 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]); }
/** * 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); } }
/** * Change the current theme property. * * @param string $theme * @return void */ public function set($theme) { if (!is_string($theme)) { throw new InvalidArgumentException('$theme parameter must be a string.'); } $this->currentTheme = $theme; $this->events->fire('theme.set', array($theme, 1)); }
/** * @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."); } }
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); }
/** * 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)); }); }
/** * Release the events on the event stack. * * @param array $events */ public function dispatch(array $events) { // For every Event's on the event array // It will get the event name from the object Namespace the fire that event // Also will write that in the log file as an information log foreach ($events as $event) { $eventName = $this->getEventName($event); $this->event->fire($eventName, $event); $this->log->info("{$eventName} was fired"); } }
public function destroy() { $payload = $this->getAuthToken(); $user = $this->driver->validate($payload); if (!$user) { throw new NotAuthorizedException(); } $this->driver->getProvider()->purge($user); $this->events->fire('auth.token.deleted', array($user)); return Response::json(array('success' => true)); }
/** * Fire the given event for the object. * * @param string $event * @param bool $halt * @return mixed */ protected function fireEvent($event, $halt = true) { if (!isset(static::$dispatcher)) { return true; } // We will append the names of the class to the event to distinguish it from // other model events that are fired, allowing us to listen on each model // event set individually instead of catching event for all the models. $event = "{$event}: " . get_class($this); return static::$dispatcher->fire($event, $this); }
/** * Dispatches an event to all registered listeners. * * @param string $eventName The name of the event to dispatch. The name of * the event is the name of the method that is * invoked on listeners. * @param Event $event The event to pass to the event handlers/listeners. * If not supplied, an empty Event instance is created. * * @return Event */ public function dispatch($eventName, Event $event = null) { if ($event === null) { $event = new Event(); } $event->setName($eventName); $event->setDispatcher($this); $this->laravelDispatcher->fire($eventName, $event); $this->symfonyDispatcher->dispatch($eventName, $event); $event->setDispatcher($this); return $event; }
/** * Execute the console command. * * @return mixed */ public function fire(Dispatcher $dispatcher) { $dispatcher->fire('zip_codes.update.starting'); $this->counties = County::all(); $url = $this->getRemoteZipCodeFile(); $parser = app(RemoteZipCodeFileParser::class); $parser->parse($url, function (RemoteZipCodeObject $object) { $municipality = $this->updateMunicipality($object->municipality_id, $object->municipality_name); $this->updateZipCode($municipality, $object->id, $object->name); }); $dispatcher->fire(new ZipCodesUpdated($this->added, $this->changed)); }
/** * @return void */ public function handle() { $params = []; if ($id = $this->argument('id')) { $params['id'] = explode(',', $id); } if ($types = $this->option('types')) { $params['types'] = explode(',', $types); } $this->dispatcher->fire(new PreEventStoreReplay()); $this->replayService->replay($params); $this->dispatcher->fire(new PostEventStoreReplay()); }
/** * Dispatch the events * * @param array $events * @param bool $log */ public function dispatch(array $events, $log = false) { foreach ($events as $event) { // Get the name of the event $eventName = $this->getEventName($event); // Fire the event $this->event->fire($eventName, [$event]); if ($log) { // Log that the event was fired $this->logger->info("Event [{$eventName}] was fired."); } } }
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); }
public function fire($event, $payload = [], $halt = false) { if ($payload instanceof Event) { $payload->setName($event); } return parent::fire($event, $payload, $halt); }
/** * Fire the morphing event. * * @return void */ protected function fireMorphingEvent() { if (!static::$events) { return; } static::$events->fire(new ResponseIsMorphing($this, $this->content)); }
/** * Raise the failed queue job event. * * @param string $connection * @param \Illuminate\Queue\Jobs\Job $job * @return void */ protected function raiseFailedJobEvent($connection, Job $job) { if ($this->events) { $data = json_decode($job->getRawBody(), true); $this->events->fire('illuminate.queue.failed', array($connection, $job, $data)); } }
/** * Delete a group * * @author Steve Montambeault * @link http://stevemo.ca * * @param $id * * @return void * * @throws \Cartalyst\Sentry\Groups\GroupNotFoundException */ public function delete($id) { $group = $this->findById($id); $old = $group; $group->delete(); $this->event->fire('groups.delete', array($old)); }
/** * 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; }
/** * Fires an event for Sentry Social. * * @param string $name * @param \Cartalyst\SentrySocial\Links\LinkInterface $link * @param mixed $provider * @param mixed $token * @param string $slug * @return mixed */ protected function fireEvent($name, LinkInterface $link, $provider, $token, $slug) { if (!isset($this->dispatcher)) { return; } return $this->dispatcher->fire("sentry.social.{$name}", array($link, $provider, $token, $slug)); }
/** * Fire the attempt event with the arguments. * * @param array $credentials * @param bool $remember * @param bool $login * @return void */ protected function fireAttemptEvent(array $credentials, $remember, $login) { if ($this->events) { $payload = array($credentials, $remember, $login); $this->events->fire('auth.attempt', $payload); } }
/** * Log the user out of the application. * * @return void */ public function logout() { $this->clearUserDataFromStorage(); if (isset($this->events)) { $this->events->fire('auth.logout', array($this->user)); } $this->user = null; }
/** * Fire given event. * * @param $event * @param \Krucas\Notification\NotificationsBag $notificationBag * @param \Krucas\Notification\Message $message * @return array|bool|null */ public function fire($event, NotificationsBag $notificationBag, Message $message) { if (!isset(static::$dispatcher)) { return true; } $event = "notification.{$event}: " . $notificationBag->getName(); return static::$dispatcher->fire($event, array($this, $notificationBag, $message)); }
/** * Fire an event and call the listeners. * * @param string $eventName * @param mixed $payload * @return Authority\Event */ public function fire($eventName, $payload = [], $halt = false) { if (is_array($payload)) { $payload['timestamp'] = new DateTime(); $payload = new Event($payload); } return parent::fire($eventName, [$payload], $halt); }
/** * Delete the model from the database. * * @param $id * * @return bool|null */ public function delete($id) { if (!($model = $this->model->findOrFail($id))) { return false; } $this->event->fire('repository.deleting', [$model]); return $model->delete(); }
public function fire($name, array $context = []) { $hookName = implode(':', explode('.', $name)); $context = array_merge([$this->project->getName()], $context); $this->log('info', $name, $context); $this->runHook($hookName, array_merge([$this], $context)); $this->dispatcher->fire($name, $context); }
/** * Fires a log event. * * @param string $level * @param string $message * @param array $context * @return void */ protected function fireLogEvent($level, $message, array $context = array()) { // If the event dispatcher is set, we will pass along the parameters to the // log listeners. These are useful for building profilers or other tools // that aggregate all of the log messages for a given "request" cycle. if (isset($this->dispatcher)) { $this->dispatcher->fire('illuminate.log', compact('level', 'message', 'context')); } }
/** * Update a permission into storage * * @author ZZK * @link http://verecom.com * * @param array $data * * @return bool */ public function update(array $data) { $perm = $this->findOrFail($data['id']); $perm->name = $data['name']; $perm->permissions = $data['permissions']; $perm->save(); $this->event->fire('permissions.update', array($perm)); return true; }
/** * Note down a message. * * @param string $message * @return void */ public function note($message, $type = null) { $note = isset($type) ? "<{$type}>{$message}</{$type}>" : $message; $this->notes[] = $note; // If the dispatcher is if (isset($this->dispatcher)) { $this->dispatcher->fire('theme.publisher.note', array($note)); } }