<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Command; use Illuminate\Console\Command; use Illuminate\Support\Facades\Event; use ModStart\Core\Events\ModuleUninstalledEvent; use ModStart\Core\Exception\BizException; use ModStart\Core\Util\FileUtil; use ModStart\Core\Util\VersionUtil; use ModStart\ModStart; use ModStart\Module\ModuleManager; class ModuleUninstallCommand extends Command { protected $signature = 'modstart:module-uninstall {module}'; public function handle() { goto FUwh2; FUwh2: $JHuzz = $this->argument('module'); goto KmOMa; vweC0: $jV_Lj = new ModuleUninstalledEvent(); goto kVyV9; KmOMa: $HHm8O = ModuleManager::isExists($JHuzz); goto Pep5e; MgUzS: ModuleManager::saveUserInstalledModules($ALWFZ); goto A8FPj; Mdo3y: $this->unPublishAsset($JHuzz); goto OnSAH; ZSkSJ: if ($HHm8O) { goto m6zTW; m6zTW: BizException::throwsIf(L('Module not installed'), !isset($ALWFZ[$JHuzz])); goto KWGBt; LfJQw: ModuleManager::callHook($JHuzz, 'hookBeforeUninstall'); goto rmEeN; KWGBt: foreach ($ALWFZ as $mTKNT => $w8Cge) { goto VbeVl; VbeVl: $Pyx_m = ModuleManager::getModuleBasic($mTKNT); goto JOd34; JOd34: if (empty($Pyx_m)) { break; } goto iDXd7; iDXd7: if (!empty($Pyx_m['require'])) { foreach ($Pyx_m['require'] as $qcEVR) { list($OKbbt, $knQyJ) = VersionUtil::parse($qcEVR); BizException::throwsIf(L('Module %s depend on %s, uninstall fail', $mTKNT, $JHuzz), $JHuzz == $OKbbt); } } goto eqjFM; eqjFM: } goto LfJQw; rmEeN: } goto yPldI; OnSAH: $this->unPublishRoot($JHuzz); goto MgUzS; SecVo: if (PHP_VERSION_ID >= 80000) { Event::dispatch($jV_Lj); } else { Event::fire($jV_Lj); } goto Pdxxr; kVyV9: $jV_Lj->name = $JHuzz; goto SecVo; yPldI: unset($ALWFZ[$JHuzz]); goto Mdo3y; Pep5e: $ALWFZ = ModuleManager::listAllInstalledModules(); goto ZSkSJ; A8FPj: ModStart::clearCache(); goto vweC0; Pdxxr: } private function unPublishAsset($JHuzz) { goto Q5Bva; Cu0uq: $cJXa5 = public_path("vendor/{$JHuzz}/"); goto lGLU4; MpnP0: $mJsUQ->deleteDirectory($cJXa5); goto QdZDQ; Q5Bva: $mJsUQ = $this->laravel['files']; goto lyID6; lGLU4: if (!file_exists($cJXa5)) { return; } goto MpnP0; lyID6: $E_44J = ModuleManager::path($JHuzz, 'Asset') . '/'; goto NFb_W; QdZDQ: $this->info("Module Asset UnPublish : {$cJXa5}"); goto V2L_Z; NFb_W: if (!file_exists($E_44J)) { return; } goto Cu0uq; V2L_Z: } private function unPublishRoot($JHuzz) { goto TU3kO; g2CNv: if (!file_exists($Bhs5s)) { return; } goto V11bA; V11bA: $Kxp3W = FileUtil::listAllFiles($Bhs5s); goto TU5yg; VKJtt: foreach ($Kxp3W as $WF06r) { goto KvItP; TzMrq: if (!file_exists($c_Wo8) && md5_file($d0Qnw) == md5_file($WF06r['pathname']) || file_exists($c_Wo8)) { goto lUdrZ; lUdrZ: unlink($d0Qnw); goto FYxb6; rg2AW: $FLKHK++; goto a3VmA; FYxb6: if (file_exists($c_Wo8)) { $gP2DQ = trim(file_get_contents($c_Wo8)); if ('__MODSTART_EMPTY_FILE__' == $gP2DQ) { unlink($c_Wo8); $this->info("Module Root Publish : {$vGV_Y}"); } else { rename($c_Wo8, $d0Qnw); $this->info("Module Root Publish : {$vGV_Y} <- {$HMrDa}"); } } goto rg2AW; a3VmA: } goto J1OS0; zxYX6: $d0Qnw = base_path($vGV_Y); goto ut2cV; KvItP: $vGV_Y = $WF06r['filename']; goto BpFNX; M0NpN: if (!file_exists($d0Qnw)) { continue; } goto TzMrq; BpFNX: $HMrDa = $vGV_Y . '._delete_.' . $JHuzz; goto zxYX6; ut2cV: $c_Wo8 = $d0Qnw . '._delete_.' . $JHuzz; goto M0NpN; J1OS0: } goto IXO7W; BWCSZ: $FLKHK = 0; goto VKJtt; TU5yg: $Kxp3W = array_filter($Kxp3W, function ($WF06r) { return $WF06r['isFile']; }); goto BWCSZ; IXO7W: $this->info("Module Root UnPublish : {$FLKHK} item(s)"); goto jUu0x; TU3kO: $Bhs5s = ModuleManager::path($JHuzz, 'ROOT'); goto g2CNv; jUu0x: } }