You are here

class CoreComposerValidator in Automatic Updates 8.2

Validates the Drupal core requirements defined in composer.json.

Hierarchy

Expanded class hierarchy of CoreComposerValidator

1 string reference to 'CoreComposerValidator'
automatic_updates.services.yml in ./automatic_updates.services.yml
automatic_updates.services.yml
1 service uses CoreComposerValidator
automatic_updates.validator.core_composer in ./automatic_updates.services.yml
Drupal\automatic_updates\Validator\CoreComposerValidator

File

src/Validator/CoreComposerValidator.php, line 14

Namespace

Drupal\automatic_updates\Validator
View source
class CoreComposerValidator implements EventSubscriberInterface {
  use StringTranslationTrait;

  /**
   * Validates the Drupal core requirements in composer.json.
   *
   * @param \Drupal\automatic_updates\Event\ReadinessCheckEvent $event
   *   The event object.
   */
  public function checkCoreRequirements(ReadinessCheckEvent $event) : void {

    // Ensure that either drupal/core or drupal/core-recommended is required.
    // If neither is, then core cannot be updated, which we consider an error
    // condition.
    $core_requirements = array_intersect($event
      ->getActiveComposer()
      ->getCorePackageNames(), [
      'drupal/core',
      'drupal/core-recommended',
    ]);
    if (empty($core_requirements)) {
      $error = ValidationResult::createError([
        $this
          ->t('Drupal core does not appear to be required in the project-level composer.json.'),
      ]);
      $event
        ->addValidationResult($error);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      AutomaticUpdatesEvents::READINESS_CHECK => [
        'checkCoreRequirements',
        1000,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CoreComposerValidator::checkCoreRequirements public function Validates the Drupal core requirements in composer.json.
CoreComposerValidator::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.