You are here

function awssdk_requirements in AWS SDK for PHP 7.3

Same name and namespace in other branches
  1. 7.5 awssdk.module \awssdk_requirements()
  2. 7.4 awssdk.module \awssdk_requirements()

Implements hook_requirements()

File

./awssdk.module, line 42
Provides primary Drupal hook implementations.

Code

function awssdk_requirements() {
  $t = get_t();
  $requirements = array();
  $info = libraries_load('awssdk');
  if (!$info['loaded']) {
    $requirements['awssdk'] = array(
      'severity' => REQUIREMENT_ERROR,
      'title' => $t('AWSSDK'),
      'value' => $t('Failed to load the AWSSDK'),
      'description' => $t('Please make sure the AWSSDK library is installed in the libraries directory. Use the drush make file for easy installation.'),
    );
  }
  else {
    global $base_url;
    $requirements['awssdk'] = array(
      'severity' => REQUIREMENT_OK,
      'title' => $t('AWSSDK'),
      'value' => $info['version'] . ' [' . l(t('compatibility test'), $base_url . '/' . $info['library path'] . '/_compatibility_test/sdk_compatibility_test.php', array(
        'external' => TRUE,
      )) . ']',
    );
    $compatible = strpos(shell_exec('php ' . $info['library path'] . '/_compatibility_test/sdk_compatibility_test_cli.php'), 'Bottom Line: Yes, you can!') !== FALSE;
    if (!$compatible) {
      $requirements['awssdk']['severity'] = REQUIREMENT_ERROR;
      $requirements['awssdk']['description'] = $t('Your PHP environment does not support the minimum requirements for the AWS SDK for PHP.');
    }
  }
  return $requirements;
}