<?php declare(strict_types=1);
namespace Shopware\Core\Checkout\Payment\SalesChannel;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Routing\Annotation\Entity;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\Routing\Annotation\Since;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route(defaults={"_routeScope"={"store-api"}})
*/
class SortedPaymentMethodRoute extends AbstractPaymentMethodRoute
{
private AbstractPaymentMethodRoute $decorated;
/**
* @internal
*/
public function __construct(AbstractPaymentMethodRoute $decorated)
{
$this->decorated = $decorated;
}
public function getDecorated(): AbstractPaymentMethodRoute
{
return $this->decorated;
}
/**
* @Since("6.2.0.0")
* @Entity("payment_method")
* @Route("/store-api/payment-method", name="store-api.payment.method", methods={"GET", "POST"})
*/
public function load(Request $request, SalesChannelContext $context, Criteria $criteria): PaymentMethodRouteResponse
{
$response = $this->getDecorated()->load($request, $context, $criteria);
$response->getPaymentMethods()->sortPaymentMethodsByPreference($context);
return $response;
}
}