vendor/shopware/core/Checkout/Customer/SalesChannel/CustomerRoute.php line 46

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Customer\SalesChannel;
  3. use Shopware\Core\Checkout\Customer\CustomerEntity;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\Framework\Plugin\Exception\DecorationPatternException;
  7. use Shopware\Core\Framework\Routing\Annotation\Entity;
  8. use Shopware\Core\Framework\Routing\Annotation\LoginRequired;
  9. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  10. use Shopware\Core\Framework\Routing\Annotation\Since;
  11. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. /**
  15.  * @Route(defaults={"_routeScope"={"store-api"}})
  16.  */
  17. class CustomerRoute extends AbstractCustomerRoute
  18. {
  19.     /**
  20.      * @var EntityRepositoryInterface
  21.      */
  22.     private $customerRepository;
  23.     /**
  24.      * @internal
  25.      */
  26.     public function __construct(
  27.         EntityRepositoryInterface $customerRepository
  28.     ) {
  29.         $this->customerRepository $customerRepository;
  30.     }
  31.     public function getDecorated(): AbstractCustomerRoute
  32.     {
  33.         throw new DecorationPatternException(self::class);
  34.     }
  35.     /**
  36.      * @Since("6.2.0.0")
  37.      * @Entity("customer")
  38.      * @Route("/store-api/account/customer", name="store-api.account.customer", methods={"GET", "POST"}, defaults={"_loginRequired"=true, "_loginRequiredAllowGuest"=true})
  39.      */
  40.     public function load(Request $requestSalesChannelContext $contextCriteria $criteriaCustomerEntity $customer): CustomerResponse
  41.     {
  42.         $criteria->setIds([$customer->getId()]);
  43.         $customerEntity $this->customerRepository->search($criteria$context->getContext())->first();
  44.         return new CustomerResponse($customerEntity);
  45.     }
  46. }