buildName example

$this->context = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);
    }

    /** * @afterClass */
    public function cleanup(): void
    {
        $this->getContainer()->get('cache.object')
            ->invalidateTags([CachedCountryRoute::buildName(TestDefaults::SALES_CHANNEL)]);
    }

    /** * @dataProvider criteriaProvider */
    public function testCriteria(Criteria $criteria): void
    {
        $context = $this->createMock(SalesChannelContext::class);
        $response = new CountryRouteResponse(
            new EntitySearchResult('country', 0, new CountryCollection(), null, $criteria$context->getContext())
        );

        
#[Route(path: '/store-api/product/{productId}/reviews', name: 'store-api.product-review.list', methods: ['POST'], defaults: ['_entity' => 'product_review'])]     public function load(string $productId, Request $request, SalesChannelContext $context, Criteria $criteria): ProductReviewRouteResponse
    {
        if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($productId$request$context$criteria);
        }

        $key = $this->generateKey($productId$request$context$criteria);

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($productId$request$context$criteria) {
            $name = self::buildName($productId);
            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($productId$request$context$criteria));

            $item->tag($this->generateTags($productId$request$response$context$criteria));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    public static function buildName(string $productId): string
    {

        return 'theme.' . $key;
    }

    /** * @return string|bool|array<string, mixed>|float|int|null */
    public function get(string $key, SalesChannelContext $context, ?string $themeId)
    {
        if ($this->fineGrainedCache) {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace][self::buildName($key)] = true;
            }
        } else {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace]['shopware.theme'] = true;
            }
        }

        $config = $this->getThemeConfig($context$themeId);

        if (\array_key_exists($key$config)) {
            return $config[$key];
        }
$created = $snippetRepository->create([$snippet], Context::createDefaultContext())->getEventByEntityName(SnippetDefinition::ENTITY_NAME);
        static::assertInstanceOf(EntityWrittenEvent::class$created);
        static::assertEquals([$snippet['id']]$created->getIds());

        $deleted = $snippetRepository->delete([['id' => $snippet['id']]], Context::createDefaultContext())->getEventByEntityName(SnippetDefinition::ENTITY_NAME);
        static::assertInstanceOf(EntityWrittenEvent::class$deleted);
        static::assertEquals([$snippet['id']]$deleted->getIds());
    }

    public function testItReplacesReservedCharacter(): void
    {
        static::assertEquals('translator.<_r_strong>', Translator::buildName('</strong>'));
    }

    public function testThemeSnippetsGetsMergedWithOverride(): void
    {
        if (!$this->getContainer()->has(ThemeService::class) || !$this->getContainer()->has('theme.repository')) {
            static::markTestSkipped('This test needs storefront to be installed.');
        }

        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)->create(
            Uuid::randomHex(),
            TestDefaults::SALES_CHANNEL
        );
if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($countryId$request$criteria$context);
        }

        $key = $this->generateKey($countryId$request$context$criteria);

        if ($key === null) {
            return $this->getDecorated()->load($countryId$request$criteria$context);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($countryId$request$criteria$context) {
            $name = self::buildName($countryId);
            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($countryId$request$criteria$context));

            $item->tag($this->generateTags($countryId$request$response$context$criteria));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    protected function getDecorated(): AbstractCountryStateRoute
    {
if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($landingPageId$request$context);
        }

        $key = $this->generateKey($landingPageId$request$context);

        if ($key === null) {
            return $this->getDecorated()->load($landingPageId$request$context);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($request$context$landingPageId) {
            $name = self::buildName($landingPageId);
            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($landingPageId$request$context));

            $item->tag($this->generateTags($landingPageId$response$request$context));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    private function generateKey(string $landingPageId, Request $request, SalesChannelContext $context): ?string
    {
/** * @param array<string, string> $parameters */
    public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
    {
        if ($domain === null) {
            $domain = 'messages';
        }

        if ($this->fineGrainedCache) {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace][self::buildName($id)] = true;
            }
        } else {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace]['shopware.translator'] = true;
            }
        }

        $catalogue = $this->getCatalogue($locale);

        // the formatter expects 2 char locale or underscore locales, `Locale::getFallback()` transforms the codes         // We use the locale from the catalogue here as that may be the fallback locale,
if ($context->hasState(...$this->states)) {
                return $this->getDecorated()->load($navigationId$request$context);
            }

            $key = $this->generateKey($navigationId$request$context);

            if ($key === null) {
                return $this->getDecorated()->load($navigationId$request$context);
            }

            $value = $this->cache->get($keyfunction DItemInterface $item) use ($navigationId$request$context) {
                $name = self::buildName($navigationId);

                $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($navigationId$request$context));

                $item->tag($this->generateTags($navigationId$response$request$context));

                return CacheValueCompressor::compress($response);
            });

            return CacheValueCompressor::uncompress($value);
        });
    }

    
if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($productId$request$context$criteria);
        }

        $key = $this->generateKey($productId$request$context$criteria);

        if ($key === null) {
            return $this->getDecorated()->load($productId$request$context$criteria);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($productId$request$context$criteria) {
            $name = self::buildName($productId);

            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($productId$request$context$criteria));

            $item->tag($this->generateTags($productId$request$response$context$criteria));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    

        return 'config.' . $key;
    }

    /** * @return array<mixed>|bool|float|int|string|null */
    public function get(string $key, ?string $salesChannelId = null)
    {
        if ($this->fineGrainedCache) {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace][self::buildName($key)] = true;
            }
        } else {
            foreach (array_keys($this->keys) as $trace) {
                $this->traces[$trace]['global.system.config'] = true;
            }
        }

        $config = $this->loader->load($salesChannelId);

        $parts = explode('.', $key);

        
if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($request$context$criteria);
        }

        $key = $this->generateKey($request$context$criteria);

        if ($key === null) {
            return $this->getDecorated()->load($request$context$criteria);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($request$context$criteria) {
            $name = self::buildName($context->getSalesChannelId());

            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($request$context$criteria));

            $item->tag($this->generateTags($request$response$context$criteria));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    
public static function getSubscribedEvents(): array
    {
        return [
            ThemeConfigChangedEvent::class => 'invalidate',
            ThemeAssignedEvent::class => 'assigned',
            ThemeConfigResetEvent::class => 'reset',
        ];
    }

    public function invalidate(ThemeConfigChangedEvent $event): void
    {
        $tags = [CachedResolvedConfigLoader::buildName($event->getThemeId())];

        if (!$this->fineGrainedCache) {
            $this->cacheInvalidator->invalidate(['shopware.theme']);

            return;
        }

        $keys = array_keys($event->getConfig());

        foreach ($keys as $key) {
            $tags[] = ThemeConfigValueAccessor::buildName($key);
        }
if ($strategy === SitemapExporterInterface::STRATEGY_LIVE) {
            return $this->getDecorated()->load($request$context);
        }

        $key = $this->generateKey($request$context);

        if ($key === null) {
            return $this->getDecorated()->load($request$context);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($request$context) {
            $name = self::buildName($context->getSalesChannelId());

            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($request$context));

            $item->tag($this->generateTags($response$request$context));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

    
'documentDate' => $operation->getConfig()['documentDate'] ?? $now,
                        'documentNumber' => $number,
                        'custom' => [
                            'invoiceNumber' => $number,
                        ],
                    ]);

                    // create version of order to ensure the document stays the same even if the order changes                     $operation->setOrderVersionId($this->orderRepository->createVersion($orderId$context, 'document'));

                    if ($operation->isStatic()) {
                        $doc = new RenderedDocument('', $number$config->buildName()$operation->getFileType()$config->jsonSerialize());
                        $result->addSuccess($orderId$doc);

                        continue;
                    }

                    /** @var LocaleEntity $locale */
                    $locale = $order->getLanguage()->getLocale();

                    $html = $this->documentTemplateRenderer->render(
                        $template,
                        [
                            
if ($context->hasState(...$this->states)) {
            return $this->getDecorated()->load($request$context$criteria);
        }

        $key = $this->generateKey($request$context$criteria);

        if ($key === null) {
            return $this->getDecorated()->load($request$context$criteria);
        }

        $value = $this->cache->get($keyfunction DItemInterface $item) use ($request$context$criteria) {
            $name = self::buildName();

            $response = $this->tracer->trace($namefn () => $this->getDecorated()->load($request$context$criteria));

            $item->tag($this->generateTags($request$response$context$criteria));

            return CacheValueCompressor::compress($response);
        });

        return CacheValueCompressor::uncompress($value);
    }

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