Drupal investigation

config.install 1.0KB

123456789101112131415161718192021222324252627282930313233
  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('Configuration directory: %type', ['%type' => CONFIG_SYNC_DIRECTORY]),
  25. 'description' => t('The directory %directory is not writable.', ['%directory' => $directory]),
  26. 'severity' => REQUIREMENT_WARNING,
  27. ];
  28. }
  29. return $requirements;
  30. }