src/AppBundle/Command/BuildPluginAppCommand.php

(开头部分) 1KB

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

<?php

namespace AppBundle\Command;

use AppBundle\Common\BlockToolkit;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class BuildPluginAppCommand extends BaseCommand
{
    protected $output;

    protected function configure()
    {
        $this->setName('build:plugin-app')
            ->addArgument('name', InputArgument::REQUIRED, 'plugin name');
    }

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

        $this->output = $output;
        $this->filesystem = new Filesystem();
        $name = $input->getArgument('name');

        $this->copyStaticFile($name);
        $this->_buildDistPackage($name);
    }

    private function copyStaticFile($pluginCode)
    {
        $this->output->writeln("<info>正在检测态资源文件 {$pluginCode}</info>");
        $rootDir = $this->getBiz()->offsetGet('kernel.root_dir');
        $originDir = $this->getOriginDir($rootDir, $pluginCode);
        $targetDir = $this->getTargetDir($rootDir, $pluginCode);
        if ($this->filesystem->exists($originDir)) {
            $this->output->writeln("<info>    *正在拷贝静态资源文件 {$originDir} -> {$targetDir}</info>");
            $this->filesystem->mirror($originDir, $targetDir, null, array('override' => true, 'delete' => true));
        } else {
            $this->output->writeln("<warning>    *未检测到静态资源文件 {$pluginCode}</>");
        }
    }

    private function getOriginDir($rootDir, $pluginCode)
    {
        $originDir = $rootDir.'/../web/static-dist/'.strtolower($pluginCode);
        if ($pluginCode == 'FavoriteReward') {
            $originDir = $rootDir.'/../web/static-dist/litetheme';
        }

        if (!$this->isPluginTheme($pluginCode)) {
            $originDir .= 'plugin';
        }

        return $originDir;
    }

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

AI 解读 AI

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

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