Commit 963df7bb authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3304367 by tedbow, bnjmnm, phenaproxima, TravisCarden: Add...

Issue #3304367 by tedbow, bnjmnm, phenaproxima, TravisCarden: Add StatusCheckEvent to report errors and warnings in the staging error to the user
parent 1db3f3ef
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\package_manager\Event;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\package_manager\ValidationResult;

/**
 * Event fired to check the status of the system to use Package Manager.
 *
 * The event's stage will be set with the type of stage that will perform the
 * operations. The stage may or may not be currently in use.
 */
class StatusCheckEvent extends PreOperationStageEvent {

  /**
   * Adds warning information to the event.
   *
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $messages
   *   One or more warning messages.
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $summary
   *   A summary of warning messages. Required if there is more than one
   *   message, optional otherwise.
   */
  public function addWarning(array $messages, ?TranslatableMarkup $summary = NULL): void {
    $this->results[] = ValidationResult::createWarning($messages, $summary);
  }

}
+2 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Event\PreOperationStageEvent;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\package_manager\Event\StatusCheckEvent;
use PhpTuf\ComposerStager\Domain\Exception\ExceptionInterface;
use PhpTuf\ComposerStager\Domain\Service\ProcessOutputCallback\ProcessOutputCallbackInterface;
use PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface;
@@ -126,6 +127,7 @@ final class ComposerExecutableValidator implements PreOperationStageValidatorInt
  public static function getSubscribedEvents() {
    return [
      PreCreateEvent::class => 'validateStagePreOperation',
      StatusCheckEvent::class => 'validateStagePreOperation',
    ];
  }

+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Drupal\package_manager\Validator;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Event\PreOperationStageEvent;
use Drupal\package_manager\Event\StatusCheckEvent;

/**
 * Validates the configuration of the cweagans/composer-patches plugin.
@@ -42,6 +43,7 @@ class ComposerPatchesValidator implements PreOperationStageValidatorInterface {
  public static function getSubscribedEvents() {
    return [
      PreCreateEvent::class => 'validateStagePreOperation',
      StatusCheckEvent::class => 'validateStagePreOperation',
    ];
  }

+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Event\PreOperationStageEvent;
use Drupal\package_manager\Event\StatusCheckEvent;

/**
 * Validates certain Composer settings.
@@ -53,6 +54,7 @@ final class ComposerSettingsValidator implements PreOperationStageValidatorInter
  public static function getSubscribedEvents() {
    return [
      PreCreateEvent::class => 'validateStagePreOperation',
      StatusCheckEvent::class => 'validateStagePreOperation',
    ];
  }

+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ use Drupal\Component\FileSystem\FileSystem;
use Drupal\Component\Utility\Bytes;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\package_manager\Event\StatusCheckEvent;
use Drupal\package_manager\PathLocator;

/**
@@ -165,6 +166,7 @@ class DiskSpaceValidator implements PreOperationStageValidatorInterface {
  public static function getSubscribedEvents() {
    return [
      PreCreateEvent::class => 'validateStagePreOperation',
      StatusCheckEvent::class => 'validateStagePreOperation',
    ];
  }

Loading