vendor/dvdw/events/src/Content/DvdwEvent/SalesChannel/CachedDvdwEventRoute.php line 72

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