config.install 943 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the config module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function config_requirements($phase) {
  10. $requirements = [];
  11. try {
  12. $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
  13. }
  14. catch (\Exception $e) {
  15. // system_requirements() guarantees that the CONFIG_SYNC_DIRECTORY exists
  16. // as the config.storage.staging service relies on it.
  17. $directory = FALSE;
  18. }
  19. // Ensure the configuration sync directory is writable. This is only a warning
  20. // because only configuration import from a tarball requires the folder to be
  21. // web writable.
  22. if ($phase !== 'install' && !is_writable($directory)) {
  23. $requirements['config directory ' . CONFIG_SYNC_DIRECTORY] = [
  24. 'title' => t('The directory %directory is not writable.', ['%directory' => $directory]),
  25. 'severity' => REQUIREMENT_WARNING,
  26. ];
  27. }
  28. return $requirements;
  29. }