function minisite_requirements in Mini site 8
Same name and namespace in other branches
- 7 minisite.install \minisite_requirements()
Implements hook_requirements().
File
- ./
minisite.install, line 30 - Contains install and update functions for Minisite.
Code
function minisite_requirements($phase) {
if ($phase != 'runtime') {
return [];
}
$requirements = [];
if ($phase == 'runtime') {
$path = Minisite::getCommonArchiveDir();
$requirements['minisite_archive'] = [
'title' => t('Minisite archive files upload directory'),
'severity' => REQUIREMENT_OK,
'value' => t('Exists (%path)', [
'%path' => $path,
]),
];
if (!\Drupal::service('file_system')
->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
$requirements['minisite_archive']['description'] = t('The Minisite archive upload directory %path could not be created due to a misconfiguration of files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', [
'%path' => LegacyWrapper::getTarget($path),
]);
$requirements['minisite_archive']['severity'] = REQUIREMENT_ERROR;
$requirements['minisite_archive']['value'] = t('Unable to create');
}
$path = Minisite::getCommonAssetDir();
$requirements['minisite_asset'] = [
'title' => t('Minisite asset files directory'),
'severity' => REQUIREMENT_OK,
'value' => t('Exists (%path)', [
'%path' => $path,
]),
];
if (!\Drupal::service('file_system')
->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
$requirements['minisite_asset']['description'] = t('The Minisite asset files directory %path could not be created due to a misconfiguration of files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', [
'%path' => LegacyWrapper::getTarget($path),
]);
$requirements['minisite_asset']['severity'] = REQUIREMENT_ERROR;
$requirements['minisite_asset']['value'] = t('Unable to create');
}
$requirements['minisite_archiver'] = [
'title' => t('Minisite archiver library'),
'severity' => REQUIREMENT_OK,
'value' => t('Present'),
];
if (!class_exists(\ZipArchive::class)) {
$requirements['minisite_archiver']['description'] = t('ZipArchive is required to extract Minisite assets from uploaded archives. Please install php-zip extension.');
$requirements['minisite_asset']['severity'] = REQUIREMENT_ERROR;
$requirements['minisite_asset']['value'] = t('Absent');
}
}
return $requirements;
}