1
0
Fork 0

Composer\Script\Event should have access to originating event details

pull/8186/head
Ken Love 2019-06-12 16:54:09 -04:00
parent 76da8d792e
commit 81a4f74b5b
2 changed files with 32 additions and 1 deletions

View File

@ -196,7 +196,9 @@ class EventDispatcher
} }
try { try {
$return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags)); $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
$scriptEvent->setOriginatingEvent($event);
$return = $this->dispatch($scriptName, $scriptEvent);
} catch (ScriptExecutionException $e) { } catch (ScriptExecutionException $e) {
$this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET); $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
throw $e; throw $e;

View File

@ -39,6 +39,11 @@ class Event extends BaseEvent
*/ */
private $devMode; private $devMode;
/**
* @var BaseEvent
*/
private $originatingEvent;
/** /**
* Constructor. * Constructor.
* *
@ -55,6 +60,7 @@ class Event extends BaseEvent
$this->composer = $composer; $this->composer = $composer;
$this->io = $io; $this->io = $io;
$this->devMode = $devMode; $this->devMode = $devMode;
$this->originatingEvent = null;
} }
/** /**
@ -86,4 +92,27 @@ class Event extends BaseEvent
{ {
return $this->devMode; return $this->devMode;
} }
/**
* Set the originating event.
*
* @return \Composer\EventDispatcher\Event|null
*/
public function getOriginatingEvent()
{
return $this->originatingEvent;
}
/**
* Get the originating event.
*
* @param \Composer\EventDispatcher\Event $event
* @return $this
*/
public function setOriginatingEvent(BaseEvent $event)
{
$this->originatingEvent = $event;
return $this;
}
} }