vendor/generationshop/consent-mode/src/Framework/GshopCookie/SalesChannel/CookieGroupRoute.php line 69

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Gshop\ConsentMode\Framework\GshopCookie\SalesChannel;
  3. use OpenApi\Annotations as OA;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter;
  7. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  8. use Shopware\Core\Framework\Routing\Annotation\Entity;
  9. use Shopware\Core\Framework\Routing\Annotation\Since;
  10. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. /**
  14.  * @Route(defaults={"_routeScope"={"store-api"}})
  15.  */
  16. class CookieGroupRoute extends AbstractCookieGroupRoute
  17. {
  18.     private EntityRepositoryInterface $cookieGroupRepo;
  19.     public function __construct(
  20.         EntityRepositoryInterface $cookieGroupRepo
  21.     )
  22.     {
  23.         $this->cookieGroupRepo $cookieGroupRepo;
  24.     }
  25.     public function getDecorated(): AbstractCookieGroupRoute
  26.     {
  27.         throw new DecorationPatternException(self::class);
  28.     }
  29.     /**
  30.      * @Since("6.2.0.0")
  31.      * @Entity("gshop_cookie_group")
  32.      * @OA\Post(
  33.      *      path="/cookieGroup",
  34.      *      summary="Fetch cookie group",
  35.      *      description="Perform a filtered search for cookie groups.",
  36.      *      operationId="readCookieGroup",
  37.      *      tags={"Store API", "System & Context"},
  38.      *      @OA\Parameter(name="Api-Basic-Parameters"),
  39.      *      @OA\Response(
  40.      *          response="200",
  41.      *          description="Entity search result containing cookie groups.",
  42.      *          @OA\JsonContent(
  43.      *              type="object",
  44.      *              allOf={
  45.      *                  @OA\Schema(ref="#/components/schemas/EntitySearchResult"),
  46.      *                  @OA\Schema(type="object",
  47.      *                      @OA\Property(
  48.      *                          type="array",
  49.      *                          property="elements",
  50.      *                          @OA\Items(ref="#/components/schemas/GshopCookieGroup")
  51.      *                      )
  52.      *                  )
  53.      *              }
  54.      *          )
  55.      *     )
  56.      * )
  57.      * @Route(path="/store-api/gshop-cookie-group", name="store-api.gshop-cookie-group", methods={"GET", "POST"})
  58.      */
  59.     public function load(Request $requestSalesChannelContext $contextCriteria $criteria): CookieGroupRouteResponse
  60.     {
  61.         $criteria->addFilter(new EqualsAnyFilter('salesChannelIds', [$context->getSalesChannelId()]));
  62.         return new CookieGroupRouteResponse($this->cookieGroupRepo->search($criteria$context->getContext()));
  63.     }
  64. }