AddonUpgradeService.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Configuration\Addon\Update;
  3. use ModulesGarden\ProxmoxAddon\Core\ModuleConstants;
  4. use Illuminate\Database\Capsule\Manager as DB;
  5. class AddonUpgradeService
  6. {
  7. public function getVersion(){
  8. if (!file_exists(ModuleConstants::getModuleRootDir() . DIRECTORY_SEPARATOR . 'moduleVersion.php'))
  9. {
  10. return;
  11. }
  12. include ModuleConstants::getModuleRootDir() . DS . 'moduleVersion.php';
  13. return $moduleVersion;
  14. }
  15. public function getDatabaseVersion(){
  16. return DB::table("tbladdonmodules")->where("module","proxmoxAddon")->where("setting","version")->value("value");
  17. }
  18. public function run(){
  19. $version = $this->getVersion();
  20. if($version && $this->getDatabaseVersion() != $version ){
  21. if(!function_exists('proxmoxAddon_upgrade')){
  22. require_once ModuleConstants::getFullPath() . DIRECTORY_SEPARATOR . "proxmoxAddon.php";
  23. }
  24. if(function_exists('proxmoxAddon_upgrade')){
  25. \proxmoxAddon_upgrade([
  26. "module"=> "proxmoxAddon",
  27. "modulelink" => "addonmodules.php?module=proxmoxAddon",
  28. "version"=> $version,
  29. "access" => 1
  30. ]);
  31. }
  32. }
  33. }
  34. }