HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/kk.ibovsl.com/vendor/dcat/laravel-admin/src/Extend/UpdateManager.php
<?php

namespace Dcat\Admin\Extend;

use Dcat\Admin\Exception\AdminException;
use Illuminate\Support\Facades\Artisan;

/**
 * Class UpdateManager.
 *
 * @see https://github.com/octobercms/october/blob/develop/modules/system/classes/UpdateManager.php
 */
class UpdateManager
{
    use Note;

    /**
     * @var Manager
     */
    protected $manager;

    /**
     * @var VersionManager
     */
    protected $versionManager;

    public function __construct(Manager $manager)
    {
        $this->manager = $manager;
        $this->versionManager = $manager->versionManager();
    }

    public function install($extension)
    {
        return $this->update($extension);
    }

    public function uninstall($extension)
    {
        return $this->rollback($extension);
    }

    public function rollback($name, ?string $stopOnVersion = null)
    {
        if (
            ! ($extension = $this->manager->get($name))
            && $this->versionManager->purge($name)
        ) {
            $this->note('<info>Purged from database:</info> '.$name);

            return $this;
        }

        if ($stopOnVersion === null) {
            $extension->uninstall();
        }

        if ($stopOnVersion && ! $this->versionManager->hasDatabaseVersion($extension, $stopOnVersion)) {
            throw new AdminException('Extension version not found');
        }

        if ($this->versionManager->remove($extension, $stopOnVersion, true)) {
            $this->note('<info>Rolled back:</info> '.$name);

            if ($currentVersion = $this->versionManager->getCurrentVersion($extension)) {
                $this->note('<info>Current Version:</info> '.$currentVersion.' ('.$this->versionManager->getCurrentVersionNote($extension).')');
            }

            return $this;
        }

        $this->note('<error>Unable to find:</error> '.$name);

        return $this;
    }

    public function update($name, ?string $stopOnVersion = null)
    {
        $name = $this->manager->getName($name);

        if (! ($extension = $this->manager->get($name))) {
            $this->note('<error>Unable to find:</error> '.$name);

            return;
        }

        $this->note($name);

        $this->versionUpdate($extension, $stopOnVersion);

        $this->publish($name);

        return $this;
    }

    /**
     * 发布扩展资源.
     *
     * @param string $name
     */
    public function publish($name)
    {
        $name = $this->manager->getName($name);

        $this->manager->get($name)->publishable();

        Artisan::call('vendor:publish', ['--force' => true, '--tag' => $name]);
    }

    protected function versionUpdate($extension, $stopOnVersion)
    {
        $this->versionManager->notes = [];
        $this->versionManager->output = $this->output;

        if ($this->versionManager->update($extension, $stopOnVersion) !== false) {
            foreach ($this->versionManager->notes as $note) {
                $this->note($note);
            }
        }
    }
}