Skip to content

Commit

Permalink
fix: terms and conditions link populated on TC journey VOL-5943 (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilindsay committed Dec 4, 2024
1 parent 3137fd3 commit bb92341
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function registerConsultantAccountAction()
}

return $this->prepareView('olcs/user-registration/index', [
'form' => $form,
'form' => $this->alterForm($form),
'pageTitle' => 'register-consultant-account.form.label'
]);
}
Expand Down Expand Up @@ -197,6 +197,23 @@ private function registerConsultantAndOperator($consultantFormData)
$this->redirect()->toRoute('user-registration');
}

private function alterForm($form)
{
// inject link into terms agreed label
$termsAgreed = $form->get('fields')->get('termsAgreed');

$label = $this->translationHelper->translateReplace(
$termsAgreed->getLabel(),
[
$this->urlHelper->fromRoute('terms-and-conditions')
]
);

$termsAgreed->setLabel($label);

return $form;
}

/**
* @param string $template
* @param array $variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,28 @@ public function addAction(): Response|ViewModel
}

return $this->prepareView('olcs/user-registration/index', [
'form' => $form,
'form' => $this->alterForm($form),
'pageTitle' => 'operator-registration.page.title'
]);
}

private function alterForm($form)
{
// inject link into terms agreed label
$termsAgreed = $form->get('fields')->get('termsAgreed');

$label = $this->translationHelper->translateReplace(
$termsAgreed->getLabel(),
[
$this->urlHelper->fromRoute('terms-and-conditions')
]
);

$termsAgreed->setLabel($label);

return $form;
}

private function prepareView(string $template, array $variables = []): ViewModel
{
$view = new ViewModel($variables);
Expand Down
21 changes: 20 additions & 1 deletion app/selfserve/module/Olcs/src/Controller/WelcomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\TranslationHelperService;
use Common\Service\Helper\UrlHelperService;
use Common\Service\Table\TableFactory;
use Dvsa\Olcs\Transfer\Command\User\AgreeTerms as AgreeTermsCmd;
use Laminas\Http\Response;
Expand Down Expand Up @@ -38,7 +39,8 @@ public function __construct(
TranslationHelperService $translationHelper,
FormHelperService $formHelper,
TableFactory $tableBuilder,
MapperManager $mapperManager
MapperManager $mapperManager,
private readonly UrlHelperService $urlHelper
) {
parent::__construct($translationHelper, $formHelper, $tableBuilder, $mapperManager);
}
Expand All @@ -56,4 +58,21 @@ public function checkConditionalDisplay()
return $this->conditionalDisplayNotMet('index');
}
}

public function alterForm($form)
{
// inject link into terms agreed label
$termsAgreed = $form->get('fields')->get('termsAgreed');

$label = $this->translationHelper->translateReplace(
$termsAgreed->getLabel(),
[
$this->urlHelper->fromRoute('terms-and-conditions')
]
);

$termsAgreed->setLabel($label);

return parent::alterForm($form);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Common\Service\Helper\FormHelperService;
use Common\Service\Helper\TranslationHelperService;
use Common\Service\Helper\UrlHelperService;
use Common\Service\Table\TableFactory;
use Psr\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
Expand All @@ -19,6 +20,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$formHelper = $container->get(FormHelperService::class);
$tableBuilder = $container->get(TableFactory::class);
$mapperManager = $container->get(MapperManager::class);
return new WelcomeController($translationHelper, $formHelper, $tableBuilder, $mapperManager);
$urlHelper = $container->get(UrlHelperService::class);

return new WelcomeController($translationHelper, $formHelper, $tableBuilder, $mapperManager, $urlHelper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class AgreeTerms
{
/**
* @Form\Name("main")
* @Form\Name("fields")
* @Form\Options({"label":""})
* @Form\ComposedObject("Olcs\Form\Model\Fieldset\AgreeTerms")
*/
Expand Down

0 comments on commit bb92341

Please sign in to comment.