\Composer\EventDispatcherEventDispatcher

The Event Dispatcher.

Example in command: $dispatcher = new EventDispatcher($this->getComposer(), $this->getApplication()->getIO()); // ... $dispatcher->dispatch(ScriptEvents::POST_INSTALL_CMD); // ...

Summary

Methods
Properties
Constants
__construct()
dispatch()
dispatchScript()
dispatchPackageEvent()
dispatchInstallerEvent()
addListener()
addSubscriber()
hasEventListeners()
No public properties found
No constants found
doDispatch()
getPhpExecCommand()
executeEventPhpScript()
checkListenerExpectedEvent()
getListeners()
getScriptListeners()
isPhpScript()
isComposerScript()
pushEvent()
popEvent()
$composer
$io
$loader
$process
$listeners
N/A
serializeCallback()
$eventStack
N/A

Properties

$composer

$composer : 

Type

$io

$io : 

Type

$loader

$loader : 

Type

$process

$process : 

Type

$listeners

$listeners : 

Type

$eventStack

$eventStack : 

Type

Methods

dispatch()

dispatch(string  $eventName, \Composer\EventDispatcher\Event  $event = null) : integer

Dispatch an event

Parameters

string $eventName

An event name

\Composer\EventDispatcher\Event $event

Returns

integer —

return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0

dispatchScript()

dispatchScript(string  $eventName, boolean  $devMode = false, array  $additionalArgs = array(), array  $flags = array()) : integer

Dispatch a script event.

Parameters

string $eventName

The constant in ScriptEvents

boolean $devMode
array $additionalArgs

Arguments passed by the user

array $flags

Optional flags to pass data not as argument

Returns

integer —

return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0

dispatchPackageEvent()

dispatchPackageEvent(string  $eventName, boolean  $devMode, \Composer\DependencyResolver\PolicyInterface  $policy, \Composer\DependencyResolver\Pool  $pool, \Composer\Repository\CompositeRepository  $installedRepo, \Composer\DependencyResolver\Request  $request, array  $operations, \Composer\DependencyResolver\Operation\OperationInterface  $operation) : integer

Dispatch a package event.

Parameters

string $eventName

The constant in PackageEvents

boolean $devMode

Whether or not we are in dev mode

\Composer\DependencyResolver\PolicyInterface $policy

The policy

\Composer\DependencyResolver\Pool $pool

The pool

\Composer\Repository\CompositeRepository $installedRepo

The installed repository

\Composer\DependencyResolver\Request $request

The request

array $operations

The list of operations

\Composer\DependencyResolver\Operation\OperationInterface $operation

The package being installed/updated/removed

Returns

integer —

return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0

dispatchInstallerEvent()

dispatchInstallerEvent(string  $eventName, boolean  $devMode, \Composer\DependencyResolver\PolicyInterface  $policy, \Composer\DependencyResolver\Pool  $pool, \Composer\Repository\CompositeRepository  $installedRepo, \Composer\DependencyResolver\Request  $request, array  $operations = array()) : integer

Dispatch a installer event.

Parameters

string $eventName

The constant in InstallerEvents

boolean $devMode

Whether or not we are in dev mode

\Composer\DependencyResolver\PolicyInterface $policy

The policy

\Composer\DependencyResolver\Pool $pool

The pool

\Composer\Repository\CompositeRepository $installedRepo

The installed repository

\Composer\DependencyResolver\Request $request

The request

array $operations

The list of operations

Returns

integer —

return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0

addListener()

addListener(string  $eventName, callable  $listener, integer  $priority) 

Add a listener for a particular event

Parameters

string $eventName

The event name - typically a constant

callable $listener

A callable expecting an event argument

integer $priority

A higher value represents a higher priority

hasEventListeners()

hasEventListeners(\Composer\EventDispatcher\Event  $event) : boolean

Checks if an event has listeners registered

Parameters

\Composer\EventDispatcher\Event $event

Returns

boolean

doDispatch()

doDispatch(\Composer\EventDispatcher\Event  $event) : integer

Triggers the listeners of an event.

Parameters

\Composer\EventDispatcher\Event $event

The event object to pass to the event handlers/listeners.

Throws

\RuntimeException|\Exception

Returns

integer —

return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0

getPhpExecCommand()

getPhpExecCommand() 

executeEventPhpScript()

executeEventPhpScript(string  $className, string  $methodName, \Composer\EventDispatcher\Event  $event) 

Parameters

string $className
string $methodName
\Composer\EventDispatcher\Event $event

Event invoking the PHP callable

getListeners()

getListeners(\Composer\EventDispatcher\Event  $event) : array

Retrieves all listeners for a given event

Parameters

\Composer\EventDispatcher\Event $event

Returns

array —

All listeners: callables and scripts

getScriptListeners()

getScriptListeners(\Composer\EventDispatcher\Event  $event) : array

Finds all listeners defined as scripts in the package

Parameters

\Composer\EventDispatcher\Event $event

Event object

Returns

array —

Listeners

isPhpScript()

isPhpScript(string  $callable) : boolean

Checks if string given references a class path and method

Parameters

string $callable

Returns

boolean

isComposerScript()

isComposerScript(string  $callable) : boolean

Checks if string given references a composer run-script

Parameters

string $callable

Returns

boolean

pushEvent()

pushEvent(\Composer\EventDispatcher\Event  $event) : \Composer\EventDispatcher\number

Push an event to the stack of active event

Parameters

\Composer\EventDispatcher\Event $event

Throws

\RuntimeException

Returns

\Composer\EventDispatcher\number

popEvent()

popEvent() : mixed

Pops the active event from the stack

Returns

mixed

serializeCallback()

serializeCallback(  $cb) 

Parameters

$cb