function simple_sitemap_requirements in Simple XML sitemap 8.3
Same name and namespace in other branches
- 8.2 simple_sitemap.install \simple_sitemap_requirements()
- 4.x simple_sitemap.install \simple_sitemap_requirements()
Implements hook_requirements().
Parameters
$phase:
Return value
array
File
- ./
simple_sitemap.install, line 16 - Module install and update procedures.
Code
function simple_sitemap_requirements($phase) {
$requirements = [];
if (!extension_loaded('xmlwriter')) {
$requirements['simple_sitemap_php_extensions'] = [
'title' => t('Simple XML Sitemap PHP extensions'),
'value' => t('Missing PHP xmlwriter extension'),
'description' => t('In order to be able to generate sitemaps, the Simple XML Sitemap module requires the <em>xmlwriter</em> PHP extension to be enabled.'),
'severity' => REQUIREMENT_ERROR,
];
}
switch ($phase) {
case 'runtime':
// todo Implement for 3.x
// /** @var \Drupal\simple_sitemap\Simplesitemap $generator */
// $generator = \Drupal::service('simple_sitemap.generator');
// $generated_ago = $generator->getGeneratedAgo();
// $cron_generation = $generator->getSetting('cron_generate');
//
// if (!$generated_ago) {
// $value = t('Not available');
// $description = t($cron_generation
// ? 'Run cron, or <a href="@generate">generate</a> the sitemap manually.'
// : 'Generation on cron run is disabled. <a href="@generate">Generate</a> the sitemap manually.', [
// '@generate' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap'
// ]
// );
// $severity = REQUIREMENT_WARNING;
// }
// else {
// $value = t('XML sitemaps are available');
// $description = t('The last generation finished @ago ago.'
// . ' ' . ($cron_generation
// ? 'Run cron, or <a href="@generate">regenerate</a> the sitemaps manually.'
// : 'Generation on cron run is disabled. <a href="@generate">Regenerate</a> the sitemaps manually.'), [
// '@ago' => $generated_ago,
// '@generate' => $GLOBALS['base_url'] . '/admin/config/search/simplesitemap'
// ]
// );
// $severity = REQUIREMENT_INFO;
// }
//
// $requirements['simple_sitemap_generated'] = [
// 'title' => 'Simple XML Sitemap',
// 'value' => $value,
// 'description' => $description,
// 'severity' => $severity,
// ];
break;
}
return $requirements;
}