You are here

function robotstxt_requirements in RobotsTxt 8

Same name and namespace in other branches
  1. 5 robotstxt.install \robotstxt_requirements()
  2. 6 robotstxt.install \robotstxt_requirements()
  3. 7 robotstxt.install \robotstxt_requirements()

Implements hook_requirements().

File

./robotstxt.install, line 36
Install, update and uninstall functions for the robotstxt module.

Code

function robotstxt_requirements($phase) {
  $requirements = [];
  switch ($phase) {
    case 'runtime':

      // Module cannot work without Clean URLs.
      $request = \Drupal::request();
      if (!RequestHelper::isCleanUrl($request)) {
        $requirements['robotstxt_cleanurl'] = [
          'title' => t('RobotsTxt'),
          'severity' => REQUIREMENT_ERROR,
          'value' => t('Clean URLs are mandatory for this module.'),
        ];
      }

      // Webservers prefer the robots.txt file on disk and does not allow menu
      // path overwrite.
      if (file_exists(DRUPAL_ROOT . '/robots.txt')) {
        $requirements['robotstxt_file'] = [
          'title' => t('RobotsTxt'),
          'severity' => REQUIREMENT_WARNING,
          'value' => t('RobotsTxt module works only if you remove the existing robots.txt file in your website root.'),
        ];
      }
  }
  return $requirements;
}