class Illuminate / Events / Dispatcher
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

Dispatcher

Implements

Uses

Properties

protected

$container Container

The IoC container instance.

Default: null
protected

$listeners array

The registered event listeners.

Default: []
protected

$wildcards array

The wildcard listeners.

Default: []
protected

$wildcardsCache array

The cached wildcard listeners.

Default: []
protected

$queueResolver callable

The queue resolver instance.

Default: null

Methods

public

__construct ( Container $container ) : void

Create a new event dispatcher instance.

Parameters

public

listen ( $events , $listener ) : void

Register an event listener with the dispatcher.

Parameters

protected

setupWildcardListen ( $event , $listener ) : void

Setup a wildcard listener callback.

Parameters

  • $event string
  • $listener Closure |string
public

hasListeners ( $eventName ) : bool

Determine if a given event has listeners.

Parameters

  • $eventName string
public

hasWildcardListeners ( $eventName ) : bool

Determine if the given event has any wildcard listeners.

Parameters

  • $eventName string
public

push ( $event , $payload ) : void

Register an event and payload to be fired later.

Parameters

  • $event string
  • $payload object|array
public

flush ( $event ) : void

Flush a set of pushed events.

Parameters

  • $event string
public

subscribe ( $subscriber ) : void

Register an event subscriber with the dispatcher.

Parameters

  • $subscriber object|string
protected

resolveSubscriber ( $subscriber ) : mixed

Resolve the subscriber instance.

Parameters

  • $subscriber object|string
public

until ( $event , $payload ) : mixed

Fire an event until the first non-null response is returned.

Parameters

  • $event string|object
  • $payload mixed
public

dispatch ( $event , $payload , $halt ) : array|null

Fire an event and call the listeners.

Parameters

  • $event string|object
  • $payload mixed
  • $halt bool
protected

parseEventAndPayload ( $event , $payload ) : array

Parse the given event and payload and prepare them for dispatching.

Parameters

  • $event mixed
  • $payload mixed
protected

shouldBroadcast ( array $payload ) : bool

Determine if the payload has a broadcastable event.

Parameters

  • $payload array
protected

broadcastWhen ( $event ) : bool

Check if the event should be broadcasted by the condition.

Parameters

  • $event mixed
protected

broadcastEvent ( $event ) : void

Broadcast the given event class.

Parameters

public

getListeners ( $eventName ) : array

Get all of the listeners for a given event name.

Parameters

  • $eventName string
protected

getWildcardListeners ( $eventName ) : array

Get the wildcard listeners for the event.

Parameters

  • $eventName string
protected

addInterfaceListeners ( $eventName , array $listeners ) : array

Add the listeners for the event's interfaces to the given array.

Parameters

  • $eventName string
  • $listeners array
protected

prepareListeners ( string $eventName ) : Closure[]

Prepare the listeners for a given event.

Parameters

  • $eventName string
public

makeListener ( $listener , $wildcard ) : Closure

Register an event listener with the dispatcher.

Parameters

  • $listener Closure |string|array
  • $wildcard bool
public

createClassListener ( $listener , $wildcard ) : Closure

Create a class based listener using the IoC container.

Parameters

  • $listener string
  • $wildcard bool
protected

createClassCallable ( $listener ) : callable

Create the class based event callable.

Parameters

  • $listener array|string
protected

parseClassCallable ( $listener ) : array

Parse the class listener into class and method.

Parameters

  • $listener string
protected

handlerShouldBeQueued ( $class ) : bool

Determine if the event handler class should be queued.

Parameters

  • $class string
protected

createQueuedHandlerCallable ( $class , $method ) : Closure

Create a callable for putting an event handler on the queue.

Parameters

  • $class string
  • $method string
protected

handlerShouldBeDispatchedAfterDatabaseTransactions ( $listener ) : bool

Determine if the given event handler should be dispatched after all database transactions have committed.

Parameters

  • $listener object|mixed
protected

createCallbackForListenerRunningAfterCommits ( $listener , $method ) : Closure

Create a callable for dispatching a listener after database transactions.

Parameters

  • $listener mixed
  • $method string
protected

handlerWantsToBeQueued ( $class , $arguments ) : bool

Determine if the event handler wants to be queued.

Parameters

  • $class string
  • $arguments array
protected

queueHandler ( $class , $method , $arguments ) : void

Queue the handler class.

Parameters

  • $class string
  • $method string
  • $arguments array
protected

createListenerAndJob ( $class , $method , $arguments ) : array

Create the listener and job for a queued listener.

Parameters

  • $class string
  • $method string
  • $arguments array
protected

propagateListenerOptions ( $listener , $job ) : mixed

Propagate listener options to the job.

Parameters

public

forget ( $event ) : void

Remove a set of listeners from the dispatcher.

Parameters

  • $event string
public

forgetPushed ( ) : void

Forget all of the pushed listeners.

protected

resolveQueue ( ) : Queue

Get the queue implementation from the resolver.

public

setQueueResolver ( callable $resolver ) : $this

Set the queue resolver implementation.

Parameters

  • $resolver callable
public

getRawListeners ( ) : array

Gets the raw, unprepared listeners.