reboot example

'offset' => $result->getOffset(),
            'total' => $result->getTotal(),
        ]);
    }

    private function rebootKernelWithoutPlugins(): ContainerInterface
    {
        /** @var Kernel $kernel */
        $kernel = $this->container->get('kernel');

        $classLoad = $kernel->getPluginLoader()->getClassLoader();
        $kernel->reboot(null, new StaticKernelPluginLoader($classLoad));

        return $kernel->getContainer();
    }
}
if ($pluginData['baseClass'] === $plugin->getBaseClass()) {
                $plugins[$i]['active'] = $plugin->getActive();
            }
        }

        /* * Reboot kernel with $plugin active=true. * * All other Requests won't have this plugin active until it's updated in the db */
        $tmpStaticPluginLoader = new StaticKernelPluginLoader($pluginLoader->getClassLoader()$pluginDir$plugins);
        $kernel->reboot(null, $tmpStaticPluginLoader);

        try {
            $newContainer = $kernel->getContainer();
        } catch (\LogicException) {
            // If symfony throws an exception when calling getContainer on a not booted kernel and catch it here             throw new \RuntimeException('Failed to reboot the kernel');
        }

        $this->container = $newContainer;
        $this->eventDispatcher = $newContainer->get('event_dispatcher');
    }

    
$kernel->handle($request);

            // the cache tag collection, collects all cache tags for a single request,             // after the request handled, the collection has to be reset for the next request             $this->cacheTagCollection->reset();
        }
    }

    private function createHttpCacheKernel(string $cacheId): HttpCache
    {
        $this->kernel->reboot(null, null, $cacheId);

        $store = $this->kernel->getContainer()->get(CacheStore::class);

        return new HttpCache($this->kernel, $store, null);
    }
}
return false;
    }

    private function warmup(string $warmupDir, string $realBuildDir): void
    {
        // create a temporary kernel         $kernel = $this->getApplication()->getKernel();
        if (!$kernel instanceof RebootableInterface) {
            throw new \LogicException('Calling "cache:clear" with a kernel that does not implement "Symfony\Component\HttpKernel\RebootableInterface" is not supported.');
        }
        $kernel->reboot($warmupDir);

        // fix references to cached files with the real cache directory name         $search = [$warmupDirstr_replace('\\', '\\\\', $warmupDir)];
        $replace = str_replace('\\', '/', $realBuildDir);
        foreach (Finder::create()->files()->in($warmupDir) as $file) {
            $content = str_replace($search$replacefile_get_contents($file)$count);
            if ($count) {
                file_put_contents($file$content);
            }
        }
    }

    
public function reboot(?string $warmupDir, ?KernelPluginLoader $pluginLoader = null, ?string $cacheId = null): void
    {
        $this->rebooting = true;

        try {
            if ($pluginLoader) {
                $this->pluginLoader = $pluginLoader;
            }
            if ($cacheId) {
                $this->cacheId = $cacheId;
            }
            parent::reboot($warmupDir);
        } finally {
            $this->rebooting = false;
        }
    }

    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
    {
        $container->setParameter('.container.dumper.inline_class_loader', $this->environment !== 'test');
        $container->setParameter('.container.dumper.inline_factories', $this->environment !== 'test');

        $confDir = $this->getProjectDir() . '/config';

        
/** * @group time-sensitive */
    public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
    {
        $kernel = $this->getKernel(['initializeBundles'][], true);
        $kernel->boot();
        $preReBoot = $kernel->getStartTime();

        sleep(3600); // Intentionally large value to detect if ClockMock ever breaks         $kernel->reboot(null);

        $this->assertGreaterThan($preReBoot$kernel->getStartTime());
    }

    public function testAnonymousKernelGeneratesValidContainerClass()
    {
        $kernel = new class('test', true) extends Kernel {
            public function registerBundles(): iterable
            {
                return [];
            }

            
        $eventDispatcherWithoutPlugins->dispatch(new UpdatePostPrepareEvent($context$currentVersion$newVersion));

        return self::SUCCESS;
    }

    private function rebootKernelWithoutPlugins(): ContainerInterface
    {
        /** @var Kernel $kernel */
        $kernel = $this->container->get('kernel');

        $classLoad = $kernel->getPluginLoader()->getClassLoader();
        $kernel->reboot(null, new StaticKernelPluginLoader($classLoad));

        return $kernel->getContainer();
    }
}
$newVersion = $containerWithoutPlugins->getParameter('kernel.shopware_version');
            if (!\is_string($newVersion)) {
                throw new \RuntimeException('Container parameter "kernel.shopware_version" needs to be a string');
            }

            /** @var EventDispatcherInterface $eventDispatcherWithoutPlugins */
            $eventDispatcherWithoutPlugins = $this->rebootKernelWithoutPlugins()->get('event_dispatcher');
            $eventDispatcherWithoutPlugins->dispatch(new UpdatePreFinishEvent($context$oldVersion$newVersion));

            $this->runMigrations($output);
        } finally {
            $kernel->reboot(null, $pluginLoader);
        }

        if ($input->getOption('skip-asset-build')) {
            $context->addState(PluginLifecycleService::STATE_SKIP_ASSET_BUILDING);
        }

        /** @var EventDispatcherInterface $eventDispatcher */
        $eventDispatcher = $this->container->get('event_dispatcher');
        $updateEvent = new UpdatePostFinishEvent($context$oldVersion$newVersion);
        $eventDispatcher->dispatch($updateEvent);

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