DeactivateContext example

$plugin,
            $dependantPlugins
        );

        if (\count($dependants) > 0) {
            throw new PluginHasActiveDependantsException($plugin->getName()$dependants);
        }

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

        $deactivateContext = new DeactivateContext(
            $pluginBaseClass,
            $shopwareContext,
            $this->shopwareVersion,
            $plugin->getVersion(),
            $this->createMigrationCollection($pluginBaseClass)
        );
        $deactivateContext->setAutoMigrate(false);

        $this->eventDispatcher->dispatch(new PluginPreDeactivateEvent($plugin$deactivateContext));

        try {
            
return $context;
    }

    /** * @throws Exception * * @return DeactivateContext */
    public function deactivatePlugin(Plugin $plugin)
    {
        $context = new DeactivateContext($plugin$this->release->getVersion()$plugin->getVersion());
        if (!$plugin->getActive()) {
            return $context;
        }

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

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

        
$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
{
}
return $context;
    }

    /** * @throws Exception * @throws \Doctrine\ORM\OptimisticLockException * * @return DeactivateContext */
    public function deactivatePlugin(Plugin $plugin)
    {
        $context = new DeactivateContext($plugin$this->release->getVersion()$plugin->getVersion());
        $bootstrap = $this->getPluginByName($plugin->getName());

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

        $bootstrap->deactivate($context);

        $plugin->setActive(false);
        $this->events->notify(PluginEvent::POST_DEACTIVATE, new PostPluginDeactivateEvent($context$bootstrap));

        $this->em->flush($plugin);

        
Home | Imprint | This part of the site doesn't use cookies.