You are here

function flag_requirements in Flag 8.4

Same name and namespace in other branches
  1. 5 flag.install \flag_requirements()
  2. 6.2 flag.install \flag_requirements()
  3. 6 flag.install \flag_requirements()
  4. 7.3 flag.install \flag_requirements()
  5. 7.2 flag.install \flag_requirements()

Implements hook_requirements().

File

./flag.install, line 64
Flag module install/schema/update hooks.

Code

function flag_requirements($phase) {
  $requirements = [];

  /*
  if ($phase == 'runtime') {
    if (\Drupal::moduleHandler()->moduleExists('translation') && !\Drupal::moduleHandler()->moduleExists('translation_helpers')) {
      $requirements['flag_translation'] = array(
        'title' => t('Flag'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('To have the flag module work with translations, you need to install and enable the <a href="http://drupal.org/project/translation_helpers">Translation helpers</a> module.'),
        'value' => t('Translation helpers module not found.'),
      );
    }
    if (\Drupal::moduleHandler()->moduleExists('session_api')) {
      if (file_exists('./robots.txt')) {
        $flag_path = url('flag') . '/';
        // We don't use url() because this may return an absolute URL when
        // language negotiation is set to 'domain'.
        $flag_path = parse_url($flag_path, PHP_URL_PATH);
        $robots_string = 'Disallow: ' . $flag_path;
        $contents = file_get_contents('./robots.txt');
        if (strpos($contents, $robots_string) === FALSE) {
          $requirements['flag_robots'] = array(
            'title' => t('Flag robots.txt problem'),
            'severity' => REQUIREMENT_WARNING,
            'description' => t('Flag module may currently be used with anonymous users, however the robots.txt file does not exclude the "@flag-path" path, which may cause search engines to randomly flag and unflag content when they index the site. It is highly recommended to add "@robots-string" to your robots.txt file (located in the root of your Drupal installation).', array('@flag-path' => $flag_path, '@robots-string' => $robots_string)),
            'value' => t('Search engines flagging content'),
          );
        }
      }
    }
  }
  */
  return $requirements;
}