Bootstrap.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. use \ModulesGarden\ProxmoxAddon\Core\ModuleConstants;
  3. use \ModulesGarden\ProxmoxAddon\Core\ServiceLocator;
  4. use \ModulesGarden\ProxmoxAddon\Core\FileReader\PathValidator;
  5. use \ModulesGarden\ProxmoxAddon\Core\FileReader\File;
  6. use \ModulesGarden\ProxmoxAddon\Core\DependencyInjection\Builder;
  7. use \ModulesGarden\ProxmoxAddon\Core\DependencyInjection\Services;
  8. if (!defined('DS'))
  9. define('DS', DIRECTORY_SEPARATOR);
  10. if (!defined('PS'))
  11. define('PS', PATH_SEPARATOR);
  12. if (!defined('CRLF'))
  13. define('CRLF', "\r\n");
  14. require_once dirname(__DIR__) . DS . "vendor" . DS . "autoload.php";
  15. /**
  16. * Initialize base values
  17. */
  18. ModuleConstants::initialize();
  19. /**
  20. * Initailize DI builder
  21. */
  22. new Builder();
  23. /**
  24. * Initialize Services
  25. */
  26. new Services();
  27. /**
  28. * Check file permission
  29. */
  30. // if (is_dir(ModuleConstants::getFullPath('storage')) === false || is_writable(ModuleConstants::getFullPath('storage')) === false || is_writable(ModuleConstants::getFullPath('storage', 'app')) === false || is_writable(ModuleConstants::getFullPath('storage', 'crons')) === false || is_writable(ModuleConstants::getFullPath('storage', 'logs')) === false)
  31. // {
  32. // File::createPaths(
  33. // ['full' => ModuleConstants::getFullPath('storage'), 'permission' => 0777], ['full' => ModuleConstants::getFullPath('storage', 'app'), 'permission' => 0777], ['full' => ModuleConstants::getFullPath('storage', 'crons'), 'permission' => 0777], ['full' => ModuleConstants::getFullPath('storage', 'logs'), 'permission' => 0777]
  34. // );
  35. // }
  36. // $pathValidator = new PathValidator();
  37. // if (!$pathValidator->validatePath(ModuleConstants::getFullPath('storage', 'logs'), true, true, true))
  38. // {
  39. // ServiceLocator::call('errorManager')->addError(
  40. // 'Bootstrap', PHP_EOL . ServiceLocator::call('lang')->absoluteT('permissionsStorage'), ['path' => ModuleConstants::getFullPath('storage')]
  41. // );
  42. // }