vendor/dvdw/events/src/Content/DvdwEvent/SalesChannel/DvdwEventRoute.php line 62

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Dvdw\Events\Content\DvdwEvent\SalesChannel;
  3. use Dvdw\Events\Content\DvdwEvent\DvdwEventCollection;
  4. use OpenApi\Annotations as OA;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Core\Framework\Routing\Annotation\Entity;
  8. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  9. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. /**
  13.  * @Route(defaults={"_routeScope"={"store-api"}})
  14.  */
  15. class DvdwEventRoute extends AbstractDvdwEventRoute
  16. {
  17.     private EntityRepository $repo;
  18.     public function __construct(
  19.         EntityRepository $repo
  20.     )
  21.     {
  22.         $this->repo $repo;
  23.     }
  24.     public function getDecorated(): AbstractDvdwEventRoute
  25.     {
  26.         throw new DecorationPatternException(self::class);
  27.     }
  28.     /**
  29.      * @OA\Post(
  30.      *      path="/dvdw-event",
  31.      *      summary="Fetch dvdw events",
  32.      *      description="Fetch the events according to criteria.",
  33.      *      operationId="readDvdwEvents",
  34.      *      tags={"Store API", "System & Context"},
  35.      *      @OA\Response(
  36.      *          response="200",
  37.      *          description="Returns a collection of events that fit the criteria.",
  38.      *          @OA\JsonContent(
  39.      *              type="object",
  40.      *              allOf={
  41.      *                  @OA\Schema(ref="#/components/schemas/EntitySearchResult"),
  42.      *                  @OA\Schema(type="object",
  43.      *                      @OA\Property(
  44.      *                          type="array",
  45.      *                          property="elements",
  46.      *                          @OA\Items(ref="#/components/schemas/DvdwEvent")
  47.      *                      )
  48.      *                  )
  49.      *              }
  50.      *          )
  51.      *      )
  52.      * )
  53.      * @Entity("dvdw_event")
  54.      * @Route(path="/store-api/dvdw-event", name="store-api.dvdw-event", methods={"GET", "POST"})
  55.      */
  56.     public function load(Request $requestCriteria $criteriaSalesChannelContext $context): DvdwEventResponse
  57.     {
  58.         /** @var DvdwEventCollection $events */
  59.         $events $this->repo->search($criteria$context->getContext())->getEntities();
  60.         return new DvdwEventResponse($events);
  61.     }
  62. }