CLI Plugin Neuinstallation

Hiho,

Ich möchte einen Vorschlag machen. Ich weiß nicht wie viele Leute das betrifft, aber es könnte, meiner Meinung nach, nützlich sein.

Ich arbeite im Moment an einem Plugin und beim Testen ist es nötig, dass bei einer Neuinstallation auch die Daten mit gelöscht werden. Deshalb möchte ich Vorschlagen das Command ‘sw:plugin:reinstall’ um eine Option zu erweitern, die genau das anstößt. Im moment ist das noch hart auf ‘false’ gesetzt. Ich hab da mal was vorbereitet:

 

setName('sw:plugin:reinstall')
            ->setDescription('Reinstalls the provided plugin')
            ->addArgument(
                'plugin',
                InputArgument::REQUIRED,
                'Name of the plugin to be installed.'
            )->addOption(
                'removedata',
            	'r',
                InputOption::VALUE_NONE,
                'if supplied plugin data will be removed'
            );
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var InstallerService $pluginManager */
        $pluginManager = $this->container->get('shopware_plugininstaller.plugin_manager');
        $pluginName = $input->getArgument('plugin');

        try {
            $plugin = $pluginManager->getPluginByName($pluginName);
        } catch (\Exception $e) {
            $output->writeln(sprintf('Plugin by name "%s" was not found.', $pluginName));
            return 1;
        }
        $rmd = $input->getOption('removedata');
        $pluginManager->uninstallPlugin($plugin, $rmd);
        $pluginManager->installPlugin($plugin);
        $pluginManager->activatePlugin($plugin);
    }
}

 

Grüße, Daniel

Hi,

danke, dass du dir die Mühe gemacht hast. Solche Änderungen kannst du am besten bei Github als Pullrequest einstellen: GitHub - shopware/shopware: Shopware 5 Repository - For Shopware 6 visit https://github.com/shopware/platform. Dann tauchst du vll. auch bald als Contributor auf :slight_smile:

Schönen Abend,

Daniel

warum auch nicht? :smiley: