Composer\Script\Event should have access to originating event details
parent
76da8d792e
commit
81a4f74b5b
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue