function adstxt_install in AdsTxt 8
Same name and namespace in other branches
- 7 adstxt.install \adstxt_install()
Implements hook_install().
File
- ./
adstxt.install, line 13 - Install, update and uninstall functions for the adstxt module.
Code
function adstxt_install() {
$content = '';
// List of candidates for import.
$files = [
DRUPAL_ROOT . '/ads.txt',
DRUPAL_ROOT . '/sites/default/default.ads.txt',
drupal_get_path('module', 'adstxt') . '/ads.txt',
];
foreach ($files as $file) {
if (file_exists($file) && is_readable($file)) {
$content = file_get_contents($file);
break;
}
}
\Drupal::configFactory()
->getEditable('adstxt.settings')
->set('content', $content)
->save();
$app_content = '';
// List of candidates for import.
$files = [
DRUPAL_ROOT . '/app-ads.txt',
DRUPAL_ROOT . '/sites/default/default.app-ads.txt',
drupal_get_path('module', 'adstxt') . '/app-ads.txt',
];
foreach ($files as $file) {
if (file_exists($file) && is_readable($file)) {
$app_content = file_get_contents($file);
break;
}
}
\Drupal::configFactory()
->getEditable('adstxt.settings')
->set('app_content', $app_content)
->save();
}