class Dispatcher (View source)

A dispatcher which dispatches signals by calling its registered slot methods and passing them the method arguments which were originally passed to the signal method.

Properties

protected ObjectManagerInterface $objectManager
protected array $slots

Information about all slots connected a certain signal.

Methods

void
injectObjectManager(ObjectManagerInterface $objectManager)

Injects the object manager

void
connect(string $signalClassName, string $signalName, mixed $slotClassNameOrObject, string $slotMethodName = '', bool $passSignalInformation = true)

Connects a signal with a slot.

void
dispatch(string $signalClassName, string $signalName, array $signalArguments = [])

Dispatches a signal by calling the registered Slot methods

array
getSlots(string $signalClassName, string $signalName)

Returns all slots which are connected with the given signal

array
getSignals()

Returns all signals with its slots

Details

void injectObjectManager(ObjectManagerInterface $objectManager)

Injects the object manager

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void connect(string $signalClassName, string $signalName, mixed $slotClassNameOrObject, string $slotMethodName = '', bool $passSignalInformation = true)

Connects a signal with a slot.

One slot can be connected with multiple signals by calling this method multiple times.

Parameters

string $signalClassName

Name of the class containing the signal

string $signalName

Name of the signal

mixed $slotClassNameOrObject

Name of the class containing the slot or the instantiated class or a Closure object

string $slotMethodName

Name of the method to be used as a slot. If $slotClassNameOrObject is a Closure object, this parameter is ignored

bool $passSignalInformation

If set to true, the last argument passed to the slot will be information about the signal (EmitterClassName::signalName)

Return Value

void

Exceptions

InvalidArgumentException

void dispatch(string $signalClassName, string $signalName, array $signalArguments = [])

Dispatches a signal by calling the registered Slot methods

Parameters

string $signalClassName

Name of the class containing the signal

string $signalName

Name of the signal

array $signalArguments

arguments passed to the signal method

Return Value

void

Exceptions

InvalidSlotException

array getSlots(string $signalClassName, string $signalName)

Returns all slots which are connected with the given signal

Parameters

string $signalClassName

Name of the class containing the signal

string $signalName

Name of the signal

Return Value

array

An array of arrays with slot information

array getSignals()

Returns all signals with its slots

Return Value

array

An array of arrays with slot information