You are here

function metatag_requirements in Metatag 8

Same name and namespace in other branches
  1. 7 metatag.install \metatag_requirements()

Implements hook_requirements().

File

./metatag.install, line 11
Requirements and update functions for the Metatag module.

Code

function metatag_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {

    // Note that no meta tags will be output while the site is in maintenance
    // mode.
    if (\Drupal::state()
      ->get('system.maintenance_mode')) {
      $requirements['metatag_maintenance_mode'] = [
        'severity' => REQUIREMENT_WARNING,
        'title' => 'Metatag',
        'value' => t('Not enabled while in maintenance mode'),
        'description' => t('Please note that while the site is in maintenance mode none of the usual meta tags will be output.'),
      ];
    }

    // Recommend the Schema.org Metatag module.
    if (!\Drupal::moduleHandler()
      ->moduleExists('schema_metatag')) {
      $requirements['metatag_schema'] = [
        'severity' => REQUIREMENT_INFO,
        'title' => 'Metatag',
        'value' => t('Schema.org Metatag is recommended'),
        'description' => t('The <a href="@module">Schema.org Metatag</a> module is highly recommended to add <a href="@jsonld">JSON-LD</a> -formatted <a href="@schema">schema.org</a> compatible data structures to the site.', [
          '@module' => 'https://www.drupal.org/project/schema_metatag',
          '@jsonld' => 'https://json-ld.org',
          '@schema' => 'https://schema.org',
        ]),
      ];
    }
    else {
      $requirements['metatag_schema'] = [
        'severity' => REQUIREMENT_OK,
        'title' => 'Metatag',
        'value' => t('Schema.org Metatag is installed'),
        'description' => t('The <a href="@module">Schema.org Metatag</a> module is installed.', [
          '@module' => 'https://www.drupal.org/project/schema_metatag',
        ]),
      ];
    }
  }
  return $requirements;
}