ClassLoader example


    public function initializePlugins()
    {
        $this->originalErrorHandler = set_error_handler([$this, 'errorHandler'], E_WARNING);

        $plugins = [];
        $shopwarePlugins = [];
        $pluginsAvailable = [];

        $classLoader = new ClassLoader();
        $classLoader->register(true);

        $activePlugins = $this->connection->query(
            'SELECT `name`, `version`, `namespace` FROM s_core_plugins WHERE `active` = 1 AND `installation_date` IS NOT NULL;'
        )->fetchAll(PDO::FETCH_UNIQUE);
        if (!\is_array($activePlugins)) {
            throw new RuntimeException('Could not load plugins from database');
        }

        foreach ($activePlugins as $pluginName => &$pluginData) {
            if (\in_array($pluginData['namespace']['ShopwarePlugins', 'ProjectPlugins'], true)) {
                

                ['code' => $expectedLocale]
            )
            ->willReturn($returns);

        return $connection;
    }

    private function getKernelWithNoPlugins(): Kernel
    {
        $pluginLoader = new StaticKernelPluginLoader(new ClassLoader());

        return new Kernel(
            'dev',
            false,
            $pluginLoader,
            'foobar'
        );
    }

    /** * @return array<string, array<string, array<string, string>>> */

class KernelPluginLoaderTest extends TestCase
{
    /** * @dataProvider classLoaderDataProvider */
    public function testClassMapAuthoritativeWillBeDeactivated(bool $enabled): void
    {
        $classLoader = new ClassLoader();
        $classLoader->setClassMapAuthoritative($enabled);

        $fakeLoader = new StaticKernelPluginLoader(
            $classLoader,
            null,
            [
                [
                    'name' => 'ExampleBundle',
                    'baseClass' => ExampleBundle::class,
                    'path' => __DIR__ . '/../_fixtures/ExampleBundle',
                    'active' => true,
                    
/** * @return array<int, array<string, string|false>> */
    public function getPluginInfos(): array
    {
        return $this->pluginInfos;
    }

    public function getClassLoader(): ClassLoader
    {
        return new ClassLoader();
    }
}
Home | Imprint | This part of the site doesn't use cookies.