AlreadyLockedException example

$this->configWriter = $configWriter;
        $this->sitemapLock = $sitemapLock;
        $this->urlFilter = $urlFilter;
    }

    /** * {@inheritdoc} */
    public function generate(Shop $shop)
    {
        if (!$this->sitemapLock->doLock($shop$this->shopwareConfig->get('sitemapRefreshTime'))) {
            throw new AlreadyLockedException(sprintf('Cannot acquire lock for shop %d', $shop->getId()));
        }

        $routerContext = Context::createFromShop($shop$this->shopwareConfig);
        $shopContext = $this->contextService->createShopContext($shop->getId()$shop->getCurrency()->getId()$shop->getCustomerGroup()->getKey());

        foreach ($this->urlProvider as $urlProvider) {
            $urlProvider->reset();
            while ($urls = $urlProvider->getUrls($routerContext$shopContext)) {
                $urls = $this->urlFilter->filter($urls(int) $shop->getId());

                if (!$urls) {
                    
null,
            $context->getSalesChannel()->getId(),
            $context->getLanguageId()
        );
    }

    private function lock(SalesChannelContext $salesChannelContext, bool $force): void
    {
        $key = $this->generateCacheKeyForSalesChannel($salesChannelContext);
        $item = $this->cache->getItem($key);
        if ($item->isHit() && !$force) {
            throw new AlreadyLockedException($salesChannelContext);
        }

        $item->set(true);
        $this->cache->save($item);
    }

    private function unlock(SalesChannelContext $salesChannelContext): void
    {
        $this->cache->deleteItem($this->generateCacheKeyForSalesChannel($salesChannelContext));
    }

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