Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

79 líneas
2.5 KiB

  1. <?php
  2. namespace Grav\Plugin\Problems;
  3. use Grav\Plugin\Problems\Base\Problem;
  4. /**
  5. * Class EssentialFolders
  6. * @package Grav\Plugin\Problems
  7. */
  8. class EssentialFolders extends Problem
  9. {
  10. public function __construct()
  11. {
  12. $this->id = 'Essential Folders';
  13. $this->class = get_class($this);
  14. $this->order = 100;
  15. $this->level = Problem::LEVEL_CRITICAL;
  16. $this->status = false;
  17. $this->help = 'https://learn.getgrav.org/basics/folder-structure';
  18. }
  19. /**
  20. * @return $this
  21. */
  22. public function process()
  23. {
  24. $essential_folders = [
  25. GRAV_ROOT => false,
  26. GRAV_ROOT . '/vendor' => false,
  27. GRAV_SYSTEM_PATH => false,
  28. GRAV_CACHE_PATH => true,
  29. GRAV_LOG_PATH => true,
  30. GRAV_TMP_PATH => true,
  31. GRAV_BACKUP_PATH => true,
  32. GRAV_WEBROOT => false,
  33. GRAV_WEBROOT . '/images' => true,
  34. GRAV_WEBROOT . '/assets' => true,
  35. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/accounts' => true,
  36. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/data' => true,
  37. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/pages' => false,
  38. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/config' => false,
  39. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/plugins/error' => false,
  40. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/plugins' => false,
  41. GRAV_WEBROOT . '/' . GRAV_USER_PATH .'/themes' => false,
  42. ];
  43. // Check for essential files & perms
  44. $file_errors = [];
  45. $file_success = [];
  46. foreach ($essential_folders as $file => $check_writable) {
  47. $file_path = (!preg_match('`^(/|[a-z]:[\\\/])`ui', $file) ? GRAV_ROOT . '/' : '') . $file;
  48. if (!is_dir($file_path)) {
  49. $file_errors[$file_path] = 'does not exist';
  50. } elseif (!$check_writable) {
  51. $file_success[$file_path] = 'exists';
  52. } elseif (!is_writable($file_path)) {
  53. $file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
  54. } else {
  55. $file_success[$file_path] = 'exists and is writable';
  56. }
  57. }
  58. if (empty($file_errors)) {
  59. $this->status = true;
  60. $this->msg = 'All folders look good!';
  61. } else {
  62. $this->status = false;
  63. $this->msg = 'There were problems with required folders:';
  64. }
  65. $this->details = ['errors' => $file_errors, 'success' => $file_success];
  66. return $this;
  67. }
  68. }