Skip to content

Commit

Permalink
Merge pull request #19 from BitBagCommerce/bug/OP-547
Browse files Browse the repository at this point in the history
OP-547: Fix for error during registration when agreements are empty
  • Loading branch information
senghe authored Sep 26, 2024
2 parents dfb0332 + 861901c commit 90fe6a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function it_process_successfully(
$resourceControllerEvent->getSubject()->willReturn($customer);
$customer->getUser()->willReturn($shopUser);
$customer->getAgreements()->willReturn($userAgreements);
$userAgreements->isEmpty()->willReturn(false);
$userAgreements->first()->willReturn($agreement);
$agreement->getContexts()->willReturn(['registration_form']);

Expand Down
3 changes: 3 additions & 0 deletions src/EventSubscriber/UserRegistrationAgreementSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function processAgreementsFromUserRegister(ResourceControllerEvent $resou

/** @var Collection $userAgreements */
$userAgreements = $customer->getAgreements();
if ($userAgreements->isEmpty()) {
return;
}

$context = $userAgreements->first()->getContexts()[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<h4 class="ui dividing header">{{ 'bitbag_sylius_agreement_plugin.ui.agreements'|trans }}</h4>

{% for agreement in form.agreements %}
Expand Down

0 comments on commit 90fe6a0

Please sign in to comment.