Kernel example

exit(1);
}

require __DIR__ . '/autoload.php';

use Shopware\Components\HttpCache\AppCache;
use Shopware\Kernel;
use Symfony\Component\HttpFoundation\Request;

$environment = getenv('SHOPWARE_ENV') ?: getenv('REDIRECT_SHOPWARE_ENV') ?: 'production';

$kernel = new Kernel($environment$environment !== 'production');
if ($kernel->isHttpCacheEnabled()) {
    $kernel = new AppCache($kernel$kernel->getHttpCacheConfig());
}

// Set commandline args as request uri // This is used for legacy cronjob routing. // e.g: /usr/bin/php shopware.php /backend/cron if (PHP_SAPI === 'cli' && isset($_SERVER['argv'][1])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['argv'][1];
    // We have to use a shutdown function to prevent "headers already sent" errors.     register_shutdown_function(function D) {
        
/** @var string $rootFile */
$rootFile = $_SERVER['SCRIPT_FILENAME'];
$configEnv = dirname($rootFile) . '/.env.installer';
if (file_exists($configEnv)) {
    $dotenv = new Dotenv();
    $dotenv->usePutenv(false)->load($configEnv);
}

$debug = true;

$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'prod', $debug);

$trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false;
if ($trustedProxies) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_HOST);
}

$request = Request::createFromGlobals();

@set_time_limit(0);
@ignore_user_abort(true);

use Symfony\Component\Routing\Router;

/** * @internal * * @covers \Shopware\WebInstaller\Kernel */
class KernelTest extends TestCase
{
    public function testKernel(): void
    {
        $kernel = new Kernel('test', true);

        static::assertSame('test', $kernel->getEnvironment());
    }

    public function testBundles(): void
    {
        $kernel = new Kernel('test', true);

        $bundles = $kernel->registerBundles();

        static::assertCount(2, $bundles);
        
// dump class contains state so we define it as factory here         $container['database.snippet_dump_iterator'] = $container->factory(function D$c) {
            $dumpFile = __DIR__ . '/../data/sql/snippets.sql';

            return new DumpIterator($dumpFile);
        });

        $container['shopware.container'] = function DContainer $c) {
            require_once SW_PATH . '/autoload.php';

            $kernel = new Kernel('production', false);
            $kernel->boot();

            $container = $kernel->getContainer();
            $container->get('models')->generateAttributeModels();

            return $container;
        };

        $container['shopware.theme_installer'] = function D$c) {
            $shopwareContainer = $c['shopware.container'];

            
'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>>> */
    private function getSnippetFixtures(): array
    {
$me->get('shopware.update.cleanup'),
                $me->get('app'),
                SW_PATH,
                $me->get('db'),
                $backupDir
            );
        };

        $container['shopware.container'] = function D) use ($me) {
            require_once SW_PATH . DIRECTORY_SEPARATOR . 'autoload.php';

            $kernel = new \Shopware\Kernel('production', false);
            $kernel->boot();

            $container = $kernel->getContainer();
            $container->get('models')->generateAttributeModels();

            return $container;
        };

        $container['shopware.theme_installer'] = function D$c) {
            $shopwareContainer = $c['shopware.container'];

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