You are here

class PendingDbUpdates in Automatic Updates 8

Pending database updates checker.

Hierarchy

Expanded class hierarchy of PendingDbUpdates

1 file declares its use of PendingDbUpdates
PendingDbUpdatesTest.php in tests/src/Kernel/ReadinessChecker/PendingDbUpdatesTest.php
1 string reference to 'PendingDbUpdates'
automatic_updates.services.yml in ./automatic_updates.services.yml
automatic_updates.services.yml
1 service uses PendingDbUpdates
automatic_updates.pending_db_updates in ./automatic_updates.services.yml
Drupal\automatic_updates\ReadinessChecker\PendingDbUpdates

File

src/ReadinessChecker/PendingDbUpdates.php, line 11

Namespace

Drupal\automatic_updates\ReadinessChecker
View source
class PendingDbUpdates implements ReadinessCheckerInterface {
  use StringTranslationTrait;

  /**
   * The update registry.
   *
   * @var \Drupal\Core\Update\UpdateRegistry
   */
  protected $updateRegistry;

  /**
   * PendingDbUpdates constructor.
   *
   * @param \Drupal\Core\Update\UpdateRegistry $update_registry
   *   The update registry.
   */
  public function __construct(UpdateRegistry $update_registry) {
    $this->updateRegistry = $update_registry;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {
    $messages = [];
    if ($this
      ->areDbUpdatesPending()) {
      $messages[] = $this
        ->t('There are pending database updates. Please run update.php.');
    }
    return $messages;
  }

  /**
   * Checks if there are pending database updates.
   *
   * @return bool
   *   TRUE if there are pending updates, otherwise FALSE.
   */
  protected function areDbUpdatesPending() {
    require_once DRUPAL_ROOT . '/core/includes/install.inc';
    require_once DRUPAL_ROOT . '/core/includes/update.inc';
    drupal_load_updates();
    $hook_updates = update_get_update_list();
    $post_updates = $this->updateRegistry
      ->getPendingUpdateFunctions();
    return (bool) array_merge($hook_updates, $post_updates);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PendingDbUpdates::$updateRegistry protected property The update registry.
PendingDbUpdates::areDbUpdatesPending protected function Checks if there are pending database updates. 1
PendingDbUpdates::run public function Run check. Overrides ReadinessCheckerInterface::run
PendingDbUpdates::__construct public function PendingDbUpdates constructor. 1
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.