<?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 SjoBi; bM4y4: $uDm81 = ModuleManager::listAllInstalledModules(); goto uG0Ux; FA25i: ModStart::clearCache(); goto CMu9w; GVE3a: $this->unPublishAsset($CiBrR); goto OweYl; uG0Ux: if ($o5wSN) { goto lM1V0; lM1V0: BizException::throwsIf(L('Module not installed'), !isset($uDm81[$CiBrR])); goto YowI1; ncc5Y: ModuleManager::callHook($CiBrR, 'hookBeforeUninstall'); goto yIdgn; YowI1: foreach ($uDm81 as $wZE_B => $c3VW7) { goto Urzrj; Urzrj: $LJ5W3 = ModuleManager::getModuleBasic($wZE_B); goto KK9Yf; KK9Yf: if (empty($LJ5W3)) { break; } goto Pg0ln; Pg0ln: if (!empty($LJ5W3['require'])) { foreach ($LJ5W3['require'] as $NPvt8) { list($gOwMM, $uTz0e) = VersionUtil::parse($NPvt8); BizException::throwsIf(L('Module %s depend on %s, uninstall fail', $wZE_B, $CiBrR), $CiBrR == $gOwMM); } } goto mOKa_; mOKa_: } goto ncc5Y; yIdgn: } goto k0sh4; OweYl: $this->unPublishRoot($CiBrR); goto lUQFV; k0sh4: unset($uDm81[$CiBrR]); goto GVE3a; IRHsI: $fPCm9->name = $CiBrR; goto Jx423; YVjGf: $o5wSN = ModuleManager::isExists($CiBrR); goto bM4y4; Jx423: if (PHP_VERSION_ID >= 80000) { Event::dispatch($fPCm9); } else { Event::fire($fPCm9); } goto MSj2X; lUQFV: ModuleManager::saveUserInstalledModules($uDm81); goto FA25i; CMu9w: $fPCm9 = new ModuleUninstalledEvent(); goto IRHsI; SjoBi: $CiBrR = $this->argument('module'); goto YVjGf; MSj2X: } private function unPublishAsset($CiBrR) { goto n8Pym; XP_WN: $this->info("Module Asset UnPublish : {$QCEgc}"); goto PjfIu; L6WuN: $KUvwa = ModuleManager::path($CiBrR, 'Asset') . '/'; goto zIzZz; zIzZz: if (!file_exists($KUvwa)) { return; } goto vL4zQ; vL4zQ: $QCEgc = public_path("vendor/{$CiBrR}/"); goto L9aI0; UcyFr: $EJRAg->deleteDirectory($QCEgc); goto XP_WN; L9aI0: if (!file_exists($QCEgc)) { return; } goto UcyFr; n8Pym: $EJRAg = $this->laravel['files']; goto L6WuN; PjfIu: } private function unPublishRoot($CiBrR) { goto htFb1; r_xeO: if (!file_exists($XhKKF)) { return; } goto pleoc; NRNo3: $i5MyN = 0; goto GRkYR; htFb1: $XhKKF = ModuleManager::path($CiBrR, 'ROOT'); goto r_xeO; pleoc: $qwIog = FileUtil::listAllFiles($XhKKF); goto eJV1w; eJV1w: $qwIog = array_filter($qwIog, function ($yHf3t) { return $yHf3t['isFile']; }); goto NRNo3; GRkYR: foreach ($qwIog as $yHf3t) { goto bCaGC; JSPaJ: if (!file_exists($wFVPr)) { continue; } goto F20DS; bCaGC: $mzZTS = $yHf3t['filename']; goto zB3bD; F20DS: if (!file_exists($MwcpB) && md5_file($wFVPr) == md5_file($yHf3t['pathname']) || file_exists($MwcpB)) { goto MpLPY; A2edD: $i5MyN++; goto Cf46f; MpLPY: unlink($wFVPr); goto N8Jvz; N8Jvz: if (file_exists($MwcpB)) { $cgjRu = trim(file_get_contents($MwcpB)); if ('__MODSTART_EMPTY_FILE__' == $cgjRu) { unlink($MwcpB); $this->info("Module Root Publish : {$mzZTS}"); } else { rename($MwcpB, $wFVPr); $this->info("Module Root Publish : {$mzZTS} <- {$xhO1v}"); } } goto A2edD; Cf46f: } goto GDd_f; PkXlX: $wFVPr = base_path($mzZTS); goto xuWb8; xuWb8: $MwcpB = $wFVPr . '._delete_.' . $CiBrR; goto JSPaJ; zB3bD: $xhO1v = $mzZTS . '._delete_.' . $CiBrR; goto PkXlX; GDd_f: } goto UHokZ; UHokZ: $this->info("Module Root UnPublish : {$i5MyN} item(s)"); goto lopLL; lopLL: } }