You are here

function entity_usage_requirements in Entity Usage 8.3

Implements hook_requirements().

File

./entity_usage.install, line 128
Install, update and uninstall functions for entity_usage module.

Code

function entity_usage_requirements($phase) {
  $requirements = [];
  if ($phase === 'runtime') {
    $needs_regenaration = \Drupal::state()
      ->get('entity_usage_needs_regeneration');
    if ($needs_regenaration) {
      $requirements['entity_usage_needs_regeneration'] = [
        'title' => t('Entity Usage'),
        'description' => t('Entity Usage has detected that usage statistics may be stale. Please visit the <a href="@batch_url">batch update</a> page and regenerate your statistics.', [
          '@batch_url' => Url::fromRoute('entity_usage.batch_update')
            ->toString(),
        ]),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}