UninstallContext example

if ($plugin->getInstalledAt() === null) {
            throw new PluginNotInstalledException($plugin->getName());
        }

        if ($plugin->getActive()) {
            $this->deactivatePlugin($plugin$shopwareContext);
        }

        $pluginBaseClassString = $plugin->getBaseClass();
        $pluginBaseClass = $this->getPluginBaseClass($pluginBaseClassString);

        $uninstallContext = new UninstallContext(
            $pluginBaseClass,
            $shopwareContext,
            $this->shopwareVersion,
            $plugin->getVersion(),
            $this->createMigrationCollection($pluginBaseClass),
            $keepUserData
        );
        $uninstallContext->setAutoMigrate(false);

        $this->eventDispatcher->dispatch(new PluginPreUninstallEvent($plugin$uninstallContext));

        


    /** * @param bool $removeData * * @throws Exception * * @return UninstallContext */
    public function uninstallPlugin(Plugin $plugin$removeData = true)
    {
        $context = new UninstallContext($plugin$this->release->getVersion()$plugin->getVersion(), !$removeData);
        if (!$plugin->getInstalled()) {
            return $context;
        }

        if (!$plugin->isLegacyPlugin()) {
            return $this->pluginInstaller->uninstallPlugin($plugin$removeData);
        }

        $result = $this->legacyPluginInstaller->uninstallPlugin($plugin$removeData);
        $this->applyLegacyResultToContext($result$context);

        
/** * @param bool $removeData * * @throws Exception * @throws \Doctrine\DBAL\DBALException * @throws \Doctrine\ORM\OptimisticLockException * * @return UninstallContext */
    public function uninstallPlugin(Plugin $plugin$removeData = true)
    {
        $context = new UninstallContext($plugin$this->release->getVersion()$plugin->getVersion(), !$removeData);
        $bootstrap = $this->getPluginByName($plugin->getName());

        $this->events->notify(PluginEvent::PRE_DEACTIVATE, new PrePluginDeactivateEvent($context$bootstrap));
        $this->events->notify(PluginEvent::PRE_UNINSTALL, new PrePluginUninstallEvent($context$bootstrap));

        $this->applyMigrations($bootstrap, AbstractPluginMigration::MODUS_UNINSTALL, !$removeData);

        $bootstrap->uninstall($context);

        $plugin->setInstalled(null);
        $plugin->setActive(false);

        
$collection = new MigrationCollection(
            new MigrationSource('asd', []),
            new MigrationRuntime(new NullConnection()new NullLogger()),
            new NullConnection()
        );

        return [
            [new PluginPostInstallEvent($pluginnew InstallContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostActivateEvent($pluginnew ActivateContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostUpdateEvent($pluginnew UpdateContext($rulePlugin$context, '', '', $collection, ''))],
            [new PluginPostDeactivateEvent($pluginnew DeactivateContext($rulePlugin$context, '', '', $collection))],
            [new PluginPostUninstallEvent($pluginnew UninstallContext($rulePlugin$context, '', '', $collection, true))],
        ];
    }
}

/** * @internal */
#[Package('business-ops')] class RulePlugin extends Plugin
{
}
Home | Imprint | This part of the site doesn't use cookies.