function amazons3_requirements in AmazonS3 7.2
Same name and namespace in other branches
- 7 amazons3.install \amazons3_requirements()
Implements hook_requirements().
File
- ./
amazons3.install, line 11 - Install, update and uninstall functions for the AmazonS3 module.
Code
function amazons3_requirements($phase) {
$t = get_t();
$requirements = array();
if ($phase != 'runtime') {
return array();
}
// Composer Manager will throw a requirements warning for us.
if (!class_exists('Drupal\\amazons3\\StreamWrapperConfiguration')) {
return array();
}
$error = NULL;
try {
$config = \Drupal\amazons3\StreamWrapperConfiguration::fromDrupalVariables();
try {
$client = \Drupal\amazons3\S3Client::factory(array(), $config
->getBucket());
\Drupal\amazons3\S3Client::validateBucketExists($config
->getBucket(), $client);
} catch (\Drupal\amazons3\Exception\S3ConnectValidationException $e) {
$error = $t($e
->getMessage());
}
} catch (\InvalidArgumentException $e) {
$error = $t($e
->getMessage());
}
if ($error) {
$configure = l($t('Configure'), 'admin/config/media/amazons3');
$requirements['amazons3_connection'] = array(
'severity' => REQUIREMENT_ERROR,
'title' => $t('AmazonS3 Configuration'),
'value' => $configure,
'description' => $error,
);
}
return $requirements;
}