<?php declare(strict_types=1);
namespace Swag\BasicExample\Core\Content\Example\SalesChannel;
use OpenApi\Annotations as OA;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
use Shopware\Core\Framework\Routing\Annotation\Entity;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\Routing\Annotation\Route;
* @Route(defaults={"_routeScope"={"store-api"}})
class ExampleRoute extends AbstractExampleRoute
protected EntityRepositoryInterface $exampleRepository;
public function __construct(EntityRepositoryInterface $exampleRepository)
$this->exampleRepository = $exampleRepository;
public function getDecorated(): AbstractExampleRoute
throw new DecorationPatternException(self::class);
* @Entity("swag_example")
* summary="This route can be used to load the swag_example by specific filters",
* operationId="readExample",
* tags={"Store API", "Example"},
* @OA\Parameter(name="Api-Basic-Parameters"),
* @OA\JsonContent(type="object",
* description="Total amount"
* property="aggregations",
* description="aggregation result"
* @OA\Items(ref="#/components/schemas/swag_example_flat")
* @Route("/store-api/example", name="store-api.example.search", methods={"GET", "POST"})
public function load(Criteria $criteria, SalesChannelContext $context): ExampleRouteResponse
return new ExampleRouteResponse($this->exampleRepository->search($criteria, $context->getContext()));