diff --git a/src/EventSubscriber/UserRegistrationAgreementSubscriber.php b/src/EventSubscriber/UserRegistrationAgreementSubscriber.php index b957a90..628f73f 100644 --- a/src/EventSubscriber/UserRegistrationAgreementSubscriber.php +++ b/src/EventSubscriber/UserRegistrationAgreementSubscriber.php @@ -49,6 +49,9 @@ public function processAgreementsFromUserRegister(ResourceControllerEvent $resou /** @var Collection $userAgreements */ $userAgreements = $customer->getAgreements(); + if ($userAgreements->isEmpty()) { + return; + } $context = $userAgreements->first()->getContexts()[0]; diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig index d576a54..02b0ce6 100644 --- a/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig +++ b/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig @@ -10,7 +10,7 @@ {{ form_row(form.user.plainPassword.first, sylius_test_form_attribute('password-first')) }} {{ form_row(form.user.plainPassword.second, sylius_test_form_attribute('password-second')) }} -{% if form.agreements is defined %} +{% if form.agreements is defined and form.agreements is not empty %}