<?php declare(strict_types=1);
namespace Dvdw\Events\Content\DvdwEvent\SalesChannel;
use Dvdw\Events\Content\DvdwEvent\DvdwEventCollection;
use OpenApi\Annotations as OA;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Routing\Annotation\Entity;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route(defaults={"_routeScope"={"store-api"}})
*/
class DvdwEventRoute extends AbstractDvdwEventRoute
{
private EntityRepository $repo;
public function __construct(
EntityRepository $repo
)
{
$this->repo = $repo;
}
public function getDecorated(): AbstractDvdwEventRoute
{
throw new DecorationPatternException(self::class);
}
/**
* @OA\Post(
* path="/dvdw-event",
* summary="Fetch dvdw events",
* description="Fetch the events according to criteria.",
* operationId="readDvdwEvents",
* tags={"Store API", "System & Context"},
* @OA\Response(
* response="200",
* description="Returns a collection of events that fit the criteria.",
* @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/DvdwEvent")
* )
* )
* }
* )
* )
* )
* @Entity("dvdw_event")
* @Route(path="/store-api/dvdw-event", name="store-api.dvdw-event", methods={"GET", "POST"})
*/
public function load(Request $request, Criteria $criteria, SalesChannelContext $context): DvdwEventResponse
{
/** @var DvdwEventCollection $events */
$events = $this->repo->search($criteria, $context->getContext())->getEntities();
return new DvdwEventResponse($events);
}
}