Eccube\Command\PluginCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->app->initialize();
        $this->app->boot();
        $mode = $input->getArgument('mode');
        $path = $input->getOption('path');
        $code = $input->getOption('code');
        $uninstallForce = $input->getOption('uninstall-force');
        $service = $this->app['eccube.service.plugin'];
        if ($mode == 'install') {
            // アーカイブからインストール
            if ($path) {
                if ($service->install($path)) {
                    $output->writeln('success');
                    return;
                }
            }
            // 設置済ファイルからインストール
            if ($code) {
                $pluginDir = $service->calcPluginDir($code);
                $service->checkPluginArchiveContent($pluginDir);
                $config = $service->readYml($pluginDir . '/config.yml');
                $event = $service->readYml($pluginDir . '/event.yml');
                $service->checkSamePlugin($config['code']);
                $service->registerPlugin($config, $event);
                $output->writeln('success');
                return;
            }
            $output->writeln('path or code is required.');
            return;
        }
        if ($mode == 'update') {
            if (empty($code)) {
                $output->writeln('code is required.');
                return;
            }
            if (empty($path)) {
                $output->writeln('path is required.');
                return;
            }
            $plugin = $this->getPluginFromCode($code);
            if ($service->update($plugin, $path)) {
                $output->writeln('success');
                return;
            }
        }
        if ($mode == 'uninstall') {
            if (empty($code)) {
                $output->writeln('code is required.');
                return;
            }
            $plugin = $this->getPluginFromCode($code);
            // ディレクトリも含め全て削除.
            if ($uninstallForce) {
                if ($service->uninstall($plugin)) {
                    $output->writeln('success');
                    return;
                }
                return;
            }
            // ディレクトリは残し, プラグインを削除.
            $pluginDir = $service->calcPluginDir($code);
            $config = $service->readYml($pluginDir . '/config.yml');
            $service->callPluginManagerMethod($config, 'disable');
            $service->callPluginManagerMethod($config, 'uninstall');
            $service->unregisterPlugin($plugin);
            $output->writeln('success');
            return;
        }
        if (in_array($mode, array('enable', 'disable'), true)) {
            if (empty($code)) {
                $output->writeln('code is required.');
                return;
            }
            $plugin = $this->getPluginFromCode($code);
            if ($service->{$mode}($plugin)) {
                $output->writeln('success');
                return;
            }
        }
        $output->writeln('undefined mode.');
    }