function filelog_install in File Log 8
Same name and namespace in other branches
- 2.0.x filelog.install \filelog_install()
Implements hook_install().
File
- ./
filelog.install, line 13 - Install functions for the filelog module.
Code
function filelog_install() {
$config = Drupal::configFactory()
->getEditable('filelog.settings');
$path = $config
->get('location');
$fileSystem = Drupal::service('file_system');
// Set up the logging directory.
if ($fileSystem
->prepareDirectory($path, $fileSystem::CREATE_DIRECTORY) || !FileSecurity::writeHtaccess($path)) {
$config
->set('enabled', TRUE);
}
else {
Drupal::messenger()
->addError(t('The logs/ directory could not be created, or is not writable. File logging is disabled.'));
}
// Check if we can compress.
if (!extension_loaded('zlib')) {
$config
->set('rotation.gzip', FALSE);
}
$config
->save();
}