<?php declare(strict_types=1);
namespace Gshop\ConsentMode\Framework\GshopCookie\SalesChannel;
use OpenApi\Annotations as OA;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\Framework\Routing\Annotation\Entity;
use Shopware\Core\Framework\Routing\Annotation\Since;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route(defaults={"_routeScope"={"store-api"}})
*/
class CookieGroupRoute extends AbstractCookieGroupRoute
{
private EntityRepositoryInterface $cookieGroupRepo;
public function __construct(
EntityRepositoryInterface $cookieGroupRepo
)
{
$this->cookieGroupRepo = $cookieGroupRepo;
}
public function getDecorated(): AbstractCookieGroupRoute
{
throw new DecorationPatternException(self::class);
}
/**
* @Since("6.2.0.0")
* @Entity("gshop_cookie_group")
* @OA\Post(
* path="/cookieGroup",
* summary="Fetch cookie group",
* description="Perform a filtered search for cookie groups.",
* operationId="readCookieGroup",
* tags={"Store API", "System & Context"},
* @OA\Parameter(name="Api-Basic-Parameters"),
* @OA\Response(
* response="200",
* description="Entity search result containing cookie groups.",
* @OA\JsonContent(
* type="object",
* allOf={
* @OA\Schema(ref="#/components/schemas/EntitySearchResult"),
* @OA\Schema(type="object",
* @OA\Property(
* type="array",
* property="elements",
* @OA\Items(ref="#/components/schemas/GshopCookieGroup")
* )
* )
* }
* )
* )
* )
* @Route(path="/store-api/gshop-cookie-group", name="store-api.gshop-cookie-group", methods={"GET", "POST"})
*/
public function load(Request $request, SalesChannelContext $context, Criteria $criteria): CookieGroupRouteResponse
{
$criteria->addFilter(new EqualsAnyFilter('salesChannelIds', [$context->getSalesChannelId()]));
return new CookieGroupRouteResponse($this->cookieGroupRepo->search($criteria, $context->getContext()));
}
}