class SandboxEventException

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\SandboxException extends \Drupal\package_manager\Exception\RuntimeException
    • class \Drupal\package_manager\Exception\SandboxEventException extends \Drupal\package_manager\Exception\SandboxException

Expanded class hierarchy of SandboxEventException

11 files declare their use of SandboxEventException
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
DuplicateInfoFileValidatorTest.php in core/modules/package_manager/tests/src/Kernel/DuplicateInfoFileValidatorTest.php
PackageManagerKernelTestBase.php in core/modules/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php

... See full list

File

core/modules/package_manager/src/Exception/SandboxEventException.php, line 18

Namespace

Drupal\package_manager\Exception
View source
class SandboxEventException extends SandboxException {
    
    /**
     * Constructs a StageEventException object.
     *
     * @param \Drupal\package_manager\Event\SandboxEvent $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(SandboxEvent $event, ?string $message = NULL, ...$arguments) {
        parent::__construct($event->sandboxManager, $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 SandboxValidationEvent) {
            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
SandboxEventException::getResultsAsText protected function Formats the validation results, if any, as plain text.
SandboxEventException::__construct public function Constructs a StageEventException object. Overrides SandboxException::__construct

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.