src/AppBundle/Command/UpgradeScriptCommand.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Command;

use Biz\Util\PluginUtil;
use Topxia\Service\Common\ServiceKernel;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UpgradeScriptCommand extends BaseCommand
{
    protected function configure()
    {
        $this->setName('util:upgrade-script')
            ->addArgument('version', InputArgument::REQUIRED, '要升级的版本号')
            ->addArgument('index', InputArgument::OPTIONAL, '执行的序号')
            ->setDescription('用于命令行中执行指定版本的升级脚本');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->initServiceKernel();

        $code = 'MAIN';
        $version = $input->getArgument('version');
        $index = 0;
        if ($input->hasArgument('index')) {
            $index = $input->getArgument('index');
        }

        $this->executeScript($code, $version, $index);
        $output->writeln('<info>执行脚本</info>');

        $this->removeCache();
        $output->writeln('<info>删除缓存</info>');

        $this->updateApp($code, $version);
        $output->writeln('<info>元数据更新</info>');
    }

    protected function executeScript($code, $version, $index = 0)
    {
        $scriptFile = $this->getServiceKernel()->getParameter('kernel.root_dir')."/../scripts/upgrade-{$version}.php";

        if (!file_exists($scriptFile)) {
            return;
        }

        include_once $scriptFile;
        $upgrade = new \EduSohoUpgrade($this->getServiceKernel()->getBiz());

        if (method_exists($upgrade, 'update')) {
            $info = $upgrade->update($index);

            if (isset($info) && !empty($info['index'])) {
                $this->executeScript($code, $version, $info['index']);
            }
        }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。