本文整理汇总了PHP中Illuminate\Events\Dispatcher::fire方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::fire方法的具体用法?PHP Dispatcher::fire怎么用?PHP Dispatcher::fire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Events\Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::fire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
/**
* @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);
}
示例2: sync
/**
* 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]);
}
示例3: dispatch
/**
* 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);
}
}
示例4: set
/**
* 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));
}
示例5: dispatch
/**
* @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.");
}
}
示例6: filter
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);
}
示例7: transferLocalImages
/**
* 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));
});
}
示例8: dispatch
/**
* 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");
}
}
示例9: destroy
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));
}
示例10: fireEvent
/**
* 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);
}
示例11: dispatch
/**
* 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;
}
示例12: fire
/**
* 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));
}
示例13: handle
/**
* @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());
}
示例14: dispatch
/**
* 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.");
}
}
}
示例15: postInstall
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);
}