Rewrite.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxVps\Core\SL;
  3. use ModulesGarden\Servers\ProxmoxVps\Core\Helper\WhmcsVersionComparator;
  4. use ModulesGarden\Servers\ProxmoxVps\Core\ModuleConstants;
  5. /**
  6. * Description of Register
  7. *
  8. * @author Rafał Ossowski <rafal.os@modulesgarden.com>
  9. */
  10. class Rewrite extends AbstractReaderYml
  11. {
  12. protected function load()
  13. {
  14. /* This function executes a different code, depending on the version of the container - WHMCS 8 has a much newer version */
  15. $version8OrHigher = (new WhmcsVersionComparator)->isWVersionHigherOrEqual('8.0.0');
  16. $dataDev = $this->readYml(ModuleConstants::getFullPath('app', 'Config', 'di', 'rewrite.yml'));
  17. $data = [];
  18. if (isset($dataDev) && isset($dataDev['class']))
  19. {
  20. foreach ($dataDev['class'] as $class)
  21. {
  22. if($version8OrHigher)
  23. {
  24. /* Adding slashes for for proper functioning if WHMCS8+ */
  25. $class['old'] = '\\'.$class['old'];
  26. $class['new'] = '\\'.$class['new'];
  27. }
  28. $data[$class['old']] = $class['new'];
  29. }
  30. }
  31. $this->data = $data;
  32. }
  33. }