redis.install 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Redis install related functions.
  5. */
  6. use \Drupal\redis\ClientFactory;
  7. /**
  8. * Implements hook_requirements().
  9. */
  10. function redis_requirements($phase) {
  11. // This module is configured via settings.php file. Using any other phase
  12. // than runtime to proceed to some consistency checks is useless.
  13. if ('runtime' !== $phase) {
  14. return [];
  15. }
  16. $requirements = [];
  17. if (ClientFactory::hasClient()) {
  18. $requirements['redis'] = [
  19. 'title' => "Redis",
  20. 'value' => t("Connected, using the <em>@name</em> client.", ['@name' => ClientFactory::getClientName()]),
  21. 'severity' => REQUIREMENT_OK,
  22. ];
  23. }
  24. else {
  25. $requirements['redis'] = [
  26. 'title' => "Redis",
  27. 'value' => t("Not connected."),
  28. 'severity' => REQUIREMENT_WARNING,
  29. 'description' => t("No Redis client connected, this module is useless thereof. Ensure that you enabled module using it or disable it."),
  30. ];
  31. }
  32. return $requirements;
  33. }