initializePlugins example

'path' => 'src/FakePlugin',
                    'autoload' => [
                        'psr-4' => [
                            'Shopware\\FakePlugin\\' => 'src/',
                        ],
                    ],
                    'managedByComposer' => true,
                ],
            ]
        );

        $kernelPluginLoader->initializePlugins($this->getContainer()->getParameter('kernel.project_dir'));

        $kernelMock
            ->expects(static::exactly(2))
            ->method('getPluginLoader')
            ->willReturn($kernelPluginLoader);

        $kernelMock
            ->expects(static::exactly(1))
            ->method('getBundles')
            ->willReturn([new BundleFixture('SomeBundle', __DIR__ . '/fixtures/caseBundleLoading/bundle')]);

        
'active' => true,
                    'managedByComposer' => false,
                    'autoload' => [
                        'psr-4' => [
                            'ExampleBundle' => '',
                        ],
                    ],
                ],
            ]
        );

        $pluginLoader->initializePlugins(__DIR__);

        $kernel = $this->createMock(KernelInterface::class);
        $kernel
            ->method('getBundle')
            ->willThrowException(new \InvalidArgumentException('asd'));

        $assetService = new AssetService(
            $filesystem,
            $filesystem,
            $kernel,
            $pluginLoader,
            
/** * @internal */
class DbalKernelPluginLoaderTest extends TestCase
{
    use PluginIntegrationTestBehaviour;

    public function testLoadNoPlugins(): void
    {
        $loader = new DbalKernelPluginLoader($this->classLoader, null, $this->connection);
        $loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertEmpty($loader->getPluginInfos());
        static::assertEmpty($loader->getPluginInstances()->all());
    }

    public function testLoadNoInit(): void
    {
        $plugin = $this->getActivePlugin();
        $this->insertPlugin($plugin);

        $loader = new DbalKernelPluginLoader($this->classLoader, null, $this->connection);
        
if ($this->debug) {
            $this->startTime = microtime(true);
        }

        if ($this->debug && !EnvironmentHelper::hasVariable('SHELL_VERBOSITY')) {
            putenv('SHELL_VERBOSITY=3');
            $_ENV['SHELL_VERBOSITY'] = 3;
            $_SERVER['SHELL_VERBOSITY'] = 3;
        }

        try {
            $this->pluginLoader->initializePlugins($this->getProjectDir());
        } catch (\Throwable $e) {
            if (\defined('\STDERR')) {
                fwrite(\STDERR, 'Warning: Failed to load plugins. Message: ' . $e->getMessage() . \PHP_EOL);
            }
        }

        // init bundles         $this->initializeBundles();

        // init container         $this->initializeContainer();

        
/** * @throws RuntimeException */
    public function refreshPluginList(DateTimeInterface $refreshDate)
    {
        $initializer = new PluginInitializer(
            $this->pdo,
            $this->pluginDirectories
        );

        $plugins = $initializer->initializePlugins();

        foreach ($plugins as $plugin) {
            $pluginInfoPath = $plugin->getPath() . '/plugin.xml';
            if (is_file($pluginInfoPath)) {
                $xmlConfigReader = new XmlPluginReader();
                $info = $xmlConfigReader->read($pluginInfoPath);
            } else {
                $info = [];
            }

            $currentPluginInfo = $this->em->getConnection()->fetchAssoc(
                

    public function boot($skipDatabase = false)
    {
        if ($this->booted) {
            return;
        }

        if (!$skipDatabase) {
            $dbConn = $this->config['db'];
            $this->connection = Components\DependencyInjection\Bridge\Db::createPDO($dbConn);
            $this->initializePlugins();
        }

        $this->initializeContainer();
        $this->initializeShopware();

        foreach ($this->getBundles() as $bundle) {
            $bundle->setContainer($this->container);

            if ((!$bundle instanceof Plugin) || $bundle->isActive()) {
                $bundle->boot();
            }

            
'active' => true,
                    'managedByComposer' => false,
                    'autoload' => [
                        'psr-4' => [
                            'ExampleBundle\\' => '',
                        ],
                    ],
                ],
            ]
        );

        $fakeLoader->initializePlugins(__DIR__);

        static::assertFalse($classLoader->isClassMapAuthoritative());
    }

    /** * @dataProvider classLoaderDataProvider */
    public function testWithComposerManaged(bool $enabled): void
    {
        $classLoader = new ClassLoader();
        $classLoader->setClassMapAuthoritative($enabled);

        
/** * @internal */
class StaticKernelPluginLoaderTest extends TestCase
{
    use PluginIntegrationTestBehaviour;

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

        static::assertEmpty($loader->getPluginInfos());
        static::assertEmpty($loader->getPluginInstances()->all());
    }

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

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


    public function testNoPlugins(): void
    {
        $before = InstalledVersions::getAllRawData();

        $modified = $before;
        $modified[0]['versions'] = [];
        InstalledVersions::reload($modified[0]);

        $loader = new ComposerPluginLoader($this->classLoader, null, []);
        $loader->initializePlugins(TEST_PROJECT_DIR);

        static::assertEmpty($loader->getPluginInfos());
        static::assertEmpty($loader->getPluginInstances()->all());
    }

    public function testWithInvalidPlugins(): void
    {
        $packages = InstalledVersions::getAllRawData();

        $modified = $packages[0];
        static::assertIsArray($modified);
        
Home | Imprint | This part of the site doesn't use cookies.