function FailureMarker::write

Writes data to marker file.

Parameters

\Drupal\package_manager\StageBase $stage: The stage.

\Drupal\Core\StringTranslation\TranslatableMarkup $message: Failure message to be added.

\Throwable|null $throwable: (optional) The throwable that caused the failure.

File

core/modules/package_manager/src/FailureMarker.php, line 60

Class

FailureMarker
Handles failure marker file operation.

Namespace

Drupal\package_manager

Code

public function write(StageBase $stage, TranslatableMarkup $message, ?\Throwable $throwable = NULL) : void {
    $data = [
        'stage_class' => get_class($stage),
        'stage_type' => $stage->getType(),
        'stage_file' => (new \ReflectionObject($stage))->getFileName(),
        'message' => (string) $message,
        'throwable_class' => $throwable ? get_class($throwable) : FALSE,
        'throwable_message' => $throwable?->getMessage() ?? 'Not available',
        'throwable_backtrace' => $throwable?->getTraceAsString() ?? 'Not available.',
    ];
    file_put_contents($this->getPath(), Yaml::dump($data));
}

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