OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.4 KiB

4 years ago
  1. <?php
  2. namespace App\Helpers;
  3. /**
  4. *
  5. *
  6. *
  7. *
  8. */
  9. class NginxTemplateHelper
  10. {
  11. // path for templates files
  12. const TEMPLATES_PATH = '/ressources/templates';
  13. // path for custom template files
  14. const CUSTOM_TEMPLATES_PATH = '/ressources/templates/custom';
  15. /**
  16. *
  17. *
  18. *
  19. * @return array
  20. *
  21. */
  22. private function getTemplates()
  23. {
  24. $results = [];
  25. array_merge(
  26. scandir(self::TEMPLATES_PATH),
  27. scandir(self::CUSTOM_TEMPLATES_PATH)
  28. );
  29. return $templates;
  30. }
  31. /**
  32. *
  33. * @param [type] $files [description]
  34. * @param [type] $templatePath [description]
  35. * @return [type] [description]
  36. */
  37. private function getTemplates($templatePath)
  38. {
  39. $results = [];
  40. foreach(scandir(base_dir().$templatePath) as $file) {
  41. if (!in_array($file, self::IGNORE_FILES)) {
  42. $results[] = [
  43. 'filename' => $file,
  44. 'path' => $templatePath
  45. ];
  46. }
  47. }
  48. return $results;
  49. }
  50. /**
  51. * getting templates
  52. *
  53. */
  54. public function find()
  55. {
  56. $results = array_merge(
  57. $this->getTemplates(self::TEMPLATES_DIR),
  58. $this->getTemplates(self::TEMPLATES_CUSTOM_DIR)
  59. );
  60. return $results;
  61. }
  62. }