You are here

class UpdateEvent in Automatic Updates 8.2

Event fired when a site is updating.

Subscribers to this event should call ::addValidationResult().

Hierarchy

  • class \Drupal\automatic_updates\Event\UpdateEvent extends \Drupal\Component\EventDispatcher\Event

Expanded class hierarchy of UpdateEvent

See also

\Drupal\automatic_updates\AutomaticUpdatesEvents

7 files declare their use of UpdateEvent
ComposerExecutableValidator.php in src/Validator/ComposerExecutableValidator.php
DiskSpaceValidator.php in src/Validator/DiskSpaceValidator.php
PendingUpdatesValidator.php in src/Validator/PendingUpdatesValidator.php
TestChecker1.php in tests/modules/automatic_updates_test/src/ReadinessChecker/TestChecker1.php
Updater.php in src/Updater.php

... See full list

File

src/Event/UpdateEvent.php, line 16

Namespace

Drupal\automatic_updates\Event
View source
class UpdateEvent extends Event {

  /**
   * The validation results.
   *
   * @var \Drupal\automatic_updates\Validation\ValidationResult[]
   */
  protected $results = [];

  /**
   * The Composer utility object for the active directory.
   *
   * @var \Drupal\package_manager\ComposerUtility
   */
  protected $activeComposer;

  /**
   * Constructs a new UpdateEvent object.
   *
   * @param \Drupal\package_manager\ComposerUtility $active_composer
   *   A Composer utility object for the active directory.
   */
  public function __construct(ComposerUtility $active_composer) {
    $this->activeComposer = $active_composer;
  }

  /**
   * Returns a Composer utility object for the active directory.
   *
   * @return \Drupal\package_manager\ComposerUtility
   *   The Composer utility object for the active directory.
   */
  public function getActiveComposer() : ComposerUtility {
    return $this->activeComposer;
  }

  /**
   * Adds a validation result.
   *
   * @param \Drupal\automatic_updates\Validation\ValidationResult $validation_result
   *   The validation result.
   */
  public function addValidationResult(ValidationResult $validation_result) : void {
    $this->results[] = $validation_result;
  }

  /**
   * Gets the validation results.
   *
   * @param int|null $severity
   *   (optional) The severity for the results to return. Should be one of the
   *   SystemManager::REQUIREMENT_* constants.
   *
   * @return \Drupal\automatic_updates\Validation\ValidationResult[]
   *   The validation results.
   */
  public function getResults(?int $severity = NULL) : array {
    if ($severity !== NULL) {
      return array_filter($this->results, function ($result) use ($severity) {
        return $result
          ->getSeverity() === $severity;
      });
    }
    return $this->results;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UpdateEvent::$activeComposer protected property The Composer utility object for the active directory.
UpdateEvent::$results protected property The validation results.
UpdateEvent::addValidationResult public function Adds a validation result.
UpdateEvent::getActiveComposer public function Returns a Composer utility object for the active directory.
UpdateEvent::getResults public function Gets the validation results.
UpdateEvent::__construct public function Constructs a new UpdateEvent object. 3