getPluginInstance example

public function testGetPluginInstance(): void
    {
        $activePluginData = $this->getActivePlugin()->jsonSerialize();
        $loader = new StaticKernelPluginLoader($this->classLoader, null, [$activePluginData]);
        $loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertCount(1, $loader->getPluginInfos());

        $class = $activePluginData['baseClass'];
        $kernelPlugin = $loader->getPluginInstances()->get($class);
        static::assertNotEmpty($kernelPlugin);
        static::assertSame($kernelPlugin$loader->getPluginInstance($class));
    }

    public function testGetPluginInstanceNotActive(): void
    {
        $pluginData = $this->getInstalledInactivePlugin()->jsonSerialize();
        $loader = new StaticKernelPluginLoader($this->classLoader, null, [$pluginData]);
        $loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertCount(1, $loader->getPluginInfos());

        $class = $pluginData['baseClass'];
        
$this->requirementValidator->validateRequirements($plugin$shopwareContext, 'activate');

        $this->eventDispatcher->dispatch(new PluginPreActivateEvent($plugin$activateContext));

        $plugin->setActive(true);

        // only skip rebuild if plugin has overwritten rebuildContainer method and source is system source (CLI)         if ($pluginBaseClass->rebuildContainer() || !$shopwareContext->getSource() instanceof SystemSource) {
            $this->rebuildContainerWithNewPluginState($plugin);
        }

        $pluginBaseClass = $this->getPluginInstance($pluginBaseClassString);
        $activateContext = new ActivateContext(
            $pluginBaseClass,
            $shopwareContext,
            $this->shopwareVersion,
            $plugin->getVersion(),
            $this->createMigrationCollection($pluginBaseClass)
        );
        $activateContext->setAutoMigrate(false);

        $pluginBaseClass->activate($activateContext);

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