class StageEventException
Exception thrown if an error related to an event occurs.
This exception is thrown when an error strictly associated with an event occurs. This is also what makes it different from StageException.
Should not be thrown by external code.
Hierarchy
- class \Drupal\package_manager\Exception\StageException extends \Drupal\package_manager\Exception\RuntimeException
- class \Drupal\package_manager\Exception\StageEventException extends \Drupal\package_manager\Exception\StageException
Expanded class hierarchy of StageEventException
12 files declare their use of StageEventException
- ComposerMinimumStabilityValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerMinimumStabilityValidatorTest.php - ComposerPatchesValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerPatchesValidatorTest.php - ComposerPluginsValidatorInsecureTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerPluginsValidatorInsecureTest.php - ComposerPluginsValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerPluginsValidatorTest.php - DuplicateInfoFileValidatorTest.php in core/
modules/ package_manager/ tests/ src/ Kernel/ DuplicateInfoFileValidatorTest.php
File
-
core/
modules/ package_manager/ src/ Exception/ StageEventException.php, line 18
Namespace
Drupal\package_manager\ExceptionView source
class StageEventException extends StageException {
/**
* Constructs a StageEventException object.
*
* @param \Drupal\package_manager\Event\StageEvent $event
* The stage event during which this exception is thrown.
* @param string|null $message
* (optional) The exception message. Defaults to a plain text representation
* of the validation results.
* @param mixed ...$arguments
* Additional arguments to pass to the parent constructor.
*/
public function __construct(StageEvent $event, ?string $message = NULL, ...$arguments) {
parent::__construct($event->stage, $message ?: $this->getResultsAsText(), ...$arguments);
}
/**
* Formats the validation results, if any, as plain text.
*
* @return string
* The results, formatted as plain text.
*/
protected function getResultsAsText() : string {
$text = '';
if ($this->event instanceof PreOperationStageEvent) {
foreach ($this->event
->getResults() as $result) {
$messages = $result->messages;
$summary = $result->summary;
if ($summary) {
array_unshift($messages, $summary);
}
$text .= implode("\n", $messages) . "\n";
}
}
return $text;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
StageEventException::getResultsAsText | protected | function | Formats the validation results, if any, as plain text. | |
StageEventException::__construct | public | function | Constructs a StageEventException object. | Overrides StageException::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.