You are here

function awssdk_requirements in AWS SDK for PHP 7.4

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

Implements hook_requirements()

1 call to awssdk_requirements()
AWSSDKUnitTest::testLibrary in ./awssdk.test
Ensure that AWS SDK libraries integration and configuration work properly.

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'), 'admin/reports/awssdk') . ']',
    );

    // Instead of calling the CLI script in a separate process to check for
    // compatibility load the capatiblity test in the same process to ensure it
    // uses the same configuration as Drupal.
    ob_start();
    include $info['library path'] . '/_compatibility_test/sdk_compatibility_test_cli.php';
    $compatible = strpos(ob_get_clean(), '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;
}