You are here

function elasticsearch_connector_requirements in Elasticsearch Connector 8

Same name and namespace in other branches
  1. 8.7 elasticsearch_connector.install \elasticsearch_connector_requirements()
  2. 8.2 elasticsearch_connector.install \elasticsearch_connector_requirements()
  3. 8.5 elasticsearch_connector.install \elasticsearch_connector_requirements()
  4. 8.6 elasticsearch_connector.install \elasticsearch_connector_requirements()
  5. 7.5 elasticsearch_connector.install \elasticsearch_connector_requirements()
  6. 7 elasticsearch_connector.install \elasticsearch_connector_requirements()
  7. 7.2 elasticsearch_connector.install \elasticsearch_connector_requirements()

Implements hook_requirements().

Check Elastica installation.

File

./elasticsearch_connector.install, line 13
The installation file for elasticsearch_connector module.

Code

function elasticsearch_connector_requirements($phase) {
  if ($phase === 'install') {
    if (version_compare(phpversion(), '5.3.9', '<')) {
      return array(
        'elasticsearch_connector' => array(
          'title' => t('The PHP version is not compatible with this module.'),
          'description' => t('The module requires PHP version bigger than or equal to version 5.3.9.'),
          'severity' => REQUIREMENT_ERROR,
          'value' => t('PHP version not compatible.'),
        ),
      );
    }
  }
  if ($phase == 'runtime') {
    if (!class_exists('\\Elasticsearch\\Client')) {
      return array(
        'elasticsearch_connector' => array(
          'title' => t('The Elasticsearch library is missing.'),
          'description' => t('The official library for Elasticsearch connection is missing.'),
          'severity' => REQUIREMENT_ERROR,
          'value' => t('Elasticsearch library missing.'),
        ),
      );
    }
    else {
      return array(
        'elasticsearch_connector' => array(
          'title' => t('Elasticsearch PHP library'),
          'description' => t('The official Elasticsearch library was correctly installed.'),
          'severity' => REQUIREMENT_OK,
          'value' => t('OK'),
        ),
      );
    }
  }
  return array();
}