function s3fs_requirements in S3 File System 8.3
Same name and namespace in other branches
- 8.2 s3fs.install \s3fs_requirements()
- 7.3 s3fs.install \s3fs_requirements()
- 7 s3fs.install \s3fs_requirements()
- 7.2 s3fs.install \s3fs_requirements()
- 4.0.x s3fs.install \s3fs_requirements()
Implements hook_requirements().
File
- ./
s3fs.install, line 16 - Install, update and uninstall functions for the S3 File System module.
Code
function s3fs_requirements($phase) {
$requirements = [];
if ($phase == 'install') {
if (!class_exists('\\Aws\\S3\\S3Client')) {
$requirements['aws_library'] = [
'description' => t('S3fs require AWS library.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
if ($phase == 'runtime') {
$config = \Drupal::config('s3fs.settings');
$credentials_file = $config
->get('credentials_file');
$useForPublic = Settings::get('s3fs.use_s3_for_public');
$useForPrivate = Settings::get('s3fs.use_s3_for_private');
if (!empty($credentials_file) && !is_file($credentials_file) && !is_readable($credentials_file)) {
$requirements['s3fs'] = [
'title' => t('S3 File System'),
'severity' => REQUIREMENT_WARNING,
'description' => t('S3 File System unable to read credentials file @file. Please verify
your settings on the <a href=":settings">S3 File System module
settings page</a>.', [
'@file' => $credentials_file,
':settings' => Url::fromRoute('s3fs.admin_settings')
->toString(),
]),
];
}
$streamWrapperManager = \Drupal::service('stream_wrapper_manager');
$requirements['s3fs_public_takeover'] = [
'title' => t('S3FS public:// Takeover'),
];
if ($useForPublic) {
if (is_subclass_of($streamWrapperManager
->getClass('public'), 'Drupal\\s3fs\\StreamWrapper\\S3fsStream')) {
$requirements['s3fs_public_takeover']['severity'] = REQUIREMENT_OK;
$requirements['s3fs_public_takeover']['value'] = t('Enabled');
$requirements['s3fs_public_takeover']['description'] = t('S3FS is processing public:// file requests.');
}
else {
$requirements['s3fs_public_takeover']['severity'] = REQUIREMENT_ERROR;
$requirements['s3fs_public_takeover']['value'] = t('Error');
$requirements['s3fs_public_takeover']['description'] = t('S3FS is configured to handle public:// files but is not currently
processing public:// requests. The most common cause for this
is failing to clear the Drupal Container Cache after enabling
public:// file handling. Please verify no other services are
attempting to handle public:// files and then rebuild the
Container Cache.');
}
}
else {
$requirements['s3fs_public_takeover']['severity'] = REQUIREMENT_OK;
$requirements['s3fs_public_takeover']['value'] = t('Disabled');
$requirements['s3fs_public_takeover']['description'] = t('S3FS takeover of public:// files is disabled.');
}
$requirements['s3fs_private_takeover'] = [
'title' => t('S3FS private:// Takeover'),
];
if ($useForPrivate) {
if (is_subclass_of($streamWrapperManager
->getClass('private'), 'Drupal\\s3fs\\StreamWrapper\\S3fsStream')) {
$requirements['s3fs_private_takeover']['severity'] = REQUIREMENT_OK;
$requirements['s3fs_private_takeover']['value'] = t('Enabled');
$requirements['s3fs_private_takeover']['description'] = t('S3FS is processing private:// file requests.');
}
else {
$requirements['s3fs_private_takeover']['severity'] = REQUIREMENT_ERROR;
$requirements['s3fs_private_takeover']['value'] = t('Error');
$requirements['s3fs_private_takeover']['description'] = t('S3FS is configured to handle private:// files but is not currently
processing private:// requests. The most common causes for this
are failing to clear the Drupal Container Cache after enabling
private:// file handling, or failing to fully configure Drupal\'s
built in private:// file handler first. Please verify
$settings[\'file_private_path\'] is configured and exists then
rebuild the Drupal Container Cache.');
}
}
else {
$requirements['s3fs_private_takeover']['severity'] = REQUIREMENT_OK;
$requirements['s3fs_private_takeover']['value'] = t('Disabled');
$requirements['s3fs_private_takeover']['description'] = t('S3FS intercept of private:// files is disabled.');
}
if (ini_get('allow_url_fopen')) {
$requirements['s3fs_allow_url_fopen'] = [
'severity' => REQUIREMENT_OK,
'title' => t('allow_url_fopen'),
'value' => t('Enabled'),
];
}
else {
$requirements['s3fs_allow_url_fopen'] = [
'severity' => REQUIREMENT_ERROR,
'title' => t('allow_url_fopen'),
'value' => t('Disabled'),
'description' => t('The S3 File System module requires that the allow_url_fopen setting be turned on in php.ini.'),
];
}
if (PHP_INT_SIZE === 8) {
$requirements['s3fs_int64'] = [
'title' => t('PHP architecture'),
'value' => t('64-bit'),
'severity' => REQUIREMENT_OK,
];
}
else {
$requirements['s3fs_int64'] = [
'title' => t('PHP architecture'),
'value' => t('32-bit'),
'description' => t('A 64-bit PHP installation is required in order to support files larger than 2GB.'),
'severity' => REQUIREMENT_WARNING,
];
}
}
return $requirements;
}