getWarmers example

$domains = $this->salesChannelDomainRepository->search($criteria, Context::createDefaultContext())->getEntities();

        $this->cacheIdLoader->write($cacheId);

        // generate all message to calculate message count         $this->createMessages($cacheId$domains);
    }

    private function createMessages(string $cacheId, SalesChannelDomainCollection $domains): void
    {
        foreach ($domains as $domain) {
            foreach ($this->registry->getWarmers() as $warmer) {
                $message = $warmer->createMessage($domain, null);

                while ($message) {
                    $offset = $message->getOffset();

                    $message->setCacheId($cacheId);
                    $message->setDomain($domain->getUrl());

                    $this->bus->dispatch($message);

                    $message = $warmer->createMessage($domain$offset);
                }
/** * @return iterable|CacheRouteWarmer[] */
    public function getWarmers(): iterable
    {
        return $this->warmers;
    }

    public function getWarmer(string $class): ?CacheRouteWarmer
    {
        foreach ($this->getWarmers() as $warmer) {
            if ($warmer::class === $class) {
                return $warmer;
            }
        }

        return null;
    }
}
Home | Imprint | This part of the site doesn't use cookies.