$composer
$composer :
The Event Dispatcher.
Example in command: $dispatcher = new EventDispatcher($this->getComposer(), $this->getApplication()->getIO()); // ... $dispatcher->dispatch(ScriptEvents::POST_INSTALL_CMD); // ...
__construct(\Composer\Composer $composer, \Composer\IO\IOInterface $io, \Composer\Util\ProcessExecutor $process = null)
Constructor.
\Composer\Composer | $composer | The composer instance |
\Composer\IO\IOInterface | $io | The IOInterface instance |
\Composer\Util\ProcessExecutor | $process |
dispatch(string $eventName, \Composer\EventDispatcher\Event $event = null) : integer
Dispatch an event
string | $eventName | An event name |
\Composer\EventDispatcher\Event | $event |
return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0
dispatchScript(string $eventName, boolean $devMode = false, array $additionalArgs = array(), array $flags = array()) : integer
Dispatch a script event.
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 |
return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0
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.
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 |
return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0
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.
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 |
return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0
addListener(string $eventName, callable $listener, integer $priority)
Add a listener for a particular event
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 |
addSubscriber(\Composer\EventDispatcher\EventSubscriberInterface $subscriber)
Adds object methods as listeners for the events in getSubscribedEvents
\Composer\EventDispatcher\EventSubscriberInterface | $subscriber |
hasEventListeners(\Composer\EventDispatcher\Event $event) : boolean
Checks if an event has listeners registered
\Composer\EventDispatcher\Event | $event |
doDispatch(\Composer\EventDispatcher\Event $event) : integer
Triggers the listeners of an event.
\Composer\EventDispatcher\Event | $event | The event object to pass to the event handlers/listeners. |
return code of the executed script if any, for php scripts a false return value is changed to 1, anything else to 0
executeEventPhpScript(string $className, string $methodName, \Composer\EventDispatcher\Event $event)
string | $className | |
string | $methodName | |
\Composer\EventDispatcher\Event | $event | Event invoking the PHP callable |
checkListenerExpectedEvent(mixed $target, \Composer\EventDispatcher\Event $event) : \Composer\EventDispatcher\Event
mixed | $target | |
\Composer\EventDispatcher\Event | $event |
getListeners(\Composer\EventDispatcher\Event $event) : array
Retrieves all listeners for a given event
\Composer\EventDispatcher\Event | $event |
All listeners: callables and scripts
getScriptListeners(\Composer\EventDispatcher\Event $event) : array
Finds all listeners defined as scripts in the package
\Composer\EventDispatcher\Event | $event | Event object |
Listeners
pushEvent(\Composer\EventDispatcher\Event $event) : \Composer\EventDispatcher\number
Push an event to the stack of active event
\Composer\EventDispatcher\Event | $event |