return new JsonResponse($response);
} #[Route(path: '/form/newsletter', name: 'frontend.form.newsletter.register.handle', defaults: ['XmlHttpRequest' => true, '_captcha' => true], methods: ['POST'])]
public function handleNewsletter(Request
$request, RequestDataBag
$data, SalesChannelContext
$context): JsonResponse
{ $subscribe =
$data->
get('option'
) === self::SUBSCRIBE;
if ($subscribe) { $response =
$this->
handleSubscribe($request,
$data,
$context);
} else { $response =
$this->
handleUnsubscribe($data,
$context);
} return new JsonResponse($response);
} /**
* @return array<int, array<string|int, mixed>>
*/
private function handleSubscribe(Request
$request, RequestDataBag
$data, SalesChannelContext
$context): array
{