class PgsqlRequirementsHooks

Hook implementations for pgsql module.

Hierarchy

Expanded class hierarchy of PgsqlRequirementsHooks

File

core/modules/pgsql/src/Hook/PgsqlRequirementsHooks.php, line 13

Namespace

Drupal\pgsql\Hook
View source
class PgsqlRequirementsHooks {
  use StringTranslationTrait;
  
  /**
   * Implements hook_update_requirements().
   *
   * Implements hook_runtime_requirements().
   */
  public function checkRequirements() : array {
    $requirements = [];
    // Test with PostgreSQL databases for the status of the pg_trgm extension.
    if (Database::isActiveConnection()) {
      $connection = Database::getConnection();
      // Set the requirement just for postgres.
      if ($connection->driver() == 'pgsql') {
        $requirements['pgsql_extension_pg_trgm'] = [
          'severity' => RequirementSeverity::OK,
          'title' => $this->t('PostgreSQL pg_trgm extension'),
          'value' => $this->t('Available'),
          'description' => $this->t('The pg_trgm PostgreSQL extension is present.'),
        ];
        // If the extension is not available, set the requirement error.
        if (!$connection->schema()
          ->extensionExists('pg_trgm')) {
          $requirements['pgsql_extension_pg_trgm']['severity'] = RequirementSeverity::Error;
          $requirements['pgsql_extension_pg_trgm']['value'] = $this->t('Not created');
          $requirements['pgsql_extension_pg_trgm']['description'] = $this->t('The <a href=":pg_trgm">pg_trgm</a> PostgreSQL extension is not present. The extension is required by Drupal to improve performance when using PostgreSQL. See <a href=":requirements">Drupal database server requirements</a> for more information.', [
            ':pg_trgm' => 'https://www.postgresql.org/docs/current/pgtrgm.html',
            ':requirements' => 'https://www.drupal.org/docs/system-requirements/database-server-requirements',
          ]);
        }
      }
    }
    return $requirements;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
PgsqlRequirementsHooks::checkRequirements public function Implements hook_update_requirements().
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
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. 1

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