findRouteValue example


        $this->defaultRoute = $defaultRoute;
    }

    /** * getCacheTime returns the time span for which the cache of the given route remains valid. * * @return int|null */
    public function getCacheTime(Request $request)
    {
        $cacheTime = $this->defaultRoute->findRouteValue($request);
        if (\is_array($cacheTime)) {
            throw new UnexpectedValueException('Cache time should be integer or null at this point');
        }

        return $cacheTime;
    }
}

    public function getNoCacheTagsForRequest(Request $request$shopId)
    {
        $tags = [];
        $autoAdmin = $this->config['admin'] ?? null;

        if (!empty($autoAdmin)) {
            $tags[] = 'admin-' . $shopId;
        }

        $configuredNoCacheTags = $this->defaultRouteService->getDefaultNoCacheTags();
        $routeTags = $this->defaultRouteService->findRouteValue($request$configuredNoCacheTags);

        if (!\is_array($routeTags)) {
            return $tags;
        }

        foreach ($routeTags as $tag) {
            if ($tag === 'slt') {
                $tags[] = 'slt';
            } else {
                $tags[] = $tag . '-' . $shopId;
            }
        }
Home | Imprint | This part of the site doesn't use cookies.