platform/src/Core/Content/Category/SalesChannel/CategoryListRoute.php line 65

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Category\SalesChannel;
  3. use OpenApi\Annotations as OA;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  5. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  6. use Shopware\Core\Framework\Routing\Annotation\Entity;
  7. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  8. use Shopware\Core\Framework\Routing\Annotation\Since;
  9. use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepositoryInterface;
  10. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. /**
  13.  * @RouteScope(scopes={"store-api"})
  14.  */
  15. class CategoryListRoute extends AbstractCategoryListRoute
  16. {
  17.     /**
  18.      * @var SalesChannelRepositoryInterface
  19.      */
  20.     private $categoryRepository;
  21.     public function __construct(SalesChannelRepositoryInterface $categoryRepository)
  22.     {
  23.         $this->categoryRepository $categoryRepository;
  24.     }
  25.     public function getDecorated(): AbstractCategoryListRoute
  26.     {
  27.         throw new DecorationPatternException(self::class);
  28.     }
  29.     /**
  30.      * @Since("6.3.2.0")
  31.      * @Entity("category")
  32.      * @OA\Post(
  33.      *      path="/category",
  34.      *      summary="Fetch a list of categories",
  35.      *      description="Perform a filtered search for categories.",
  36.      *      operationId="readCategoryList",
  37.      *      tags={"Store API", "Category"},
  38.      *      @OA\Parameter(name="Api-Basic-Parameters"),
  39.      *      @OA\Response(
  40.      *          response="200",
  41.      *          description="Entity search result containing categories.",
  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/Category")
  51.      *                      )
  52.      *                  )
  53.      *              }
  54.      *          )
  55.      *     )
  56.      * )
  57.      * @Route("/store-api/category", name="store-api.category.search", methods={"GET", "POST"})
  58.      */
  59.     public function load(Criteria $criteriaSalesChannelContext $context): CategoryListRouteResponse
  60.     {
  61.         return new CategoryListRouteResponse($this->categoryRepository->search($criteria$context));
  62.     }
  63. }