Composer\Script\Event should have access to originating event details
parent
76da8d792e
commit
81a4f74b5b
|
@ -196,7 +196,9 @@ class EventDispatcher
|
|||
}
|
||||
|
||||
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) {
|
||||
$this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
|
||||
throw $e;
|
||||
|
|
|
@ -39,6 +39,11 @@ class Event extends BaseEvent
|
|||
*/
|
||||
private $devMode;
|
||||
|
||||
/**
|
||||
* @var BaseEvent
|
||||
*/
|
||||
private $originatingEvent;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -55,6 +60,7 @@ class Event extends BaseEvent
|
|||
$this->composer = $composer;
|
||||
$this->io = $io;
|
||||
$this->devMode = $devMode;
|
||||
$this->originatingEvent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,4 +92,27 @@ class Event extends BaseEvent
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue