Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / requirements.twig
1 /**
2  * Implements hook_requirements().
3  */
4 function {{ machine_name }}_requirements($phase) {
5   $requirements = [];
6
7   // Report Drupal version
8   if ($phase == 'runtime') {
9     $requirements['drupal'] = [
10       'title' => t('Drupal'),
11       'value' => \Drupal::VERSION,
12       'severity' => REQUIREMENT_INFO
13     ];
14   }
15
16   // Test PHP version
17   $requirements['php'] = [
18     'title' => t('PHP'),
19     'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(),
20   ];
21   if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
22     $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]);
23     $requirements['php']['severity'] = REQUIREMENT_ERROR;
24   }
25
26   // Report cron status
27   if ($phase == 'runtime') {
28     $cron_last = \Drupal::state()->get('system.cron_last');
29
30     if (is_numeric($cron_last)) {
31       $requirements['cron']['value'] = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]);
32     }
33     else {
34       $requirements['cron'] = [
35         'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for <a href=":url">configuring cron jobs</a>.', [':url' => 'https://www.drupal.org/cron']),
36         'severity' => REQUIREMENT_ERROR,
37         'value' => t('Never run'),
38       ];
39     }
40
41     $requirements['cron']['description'] .= ' ' . t('You can <a href=":cron">run cron manually</a>.', [':cron' => \Drupal::url('system.run_cron')]);
42
43     $requirements['cron']['title'] = t('Cron maintenance tasks');
44   }
45
46   return $requirements;
47 }