Skip to content

Commit

Permalink
fix: amend for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sdh100shaun committed Dec 16, 2024
1 parent a98f784 commit d5ec492
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/selfserve/module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
'route' => 'operator-confirm[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'operatorConfirm'
'action' => 'add'
]
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function addAction()
// no admin, move to operator representation but store licence number and admin state in session
$this->consultantRegistrationSession->setExistingLicence($licenceNumber);
$this->consultantRegistrationSession->setOperatorAdmin($checks['hasOperatorAdmin']);
$this->redirect()->toRoute('user-registration/operator');
$this->redirect()->toRoute('user-registration/operator-confirm');
} else {
$this->redirect()->toRoute('user-registration/contact-your-administrator');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use LmcRbacMvc\Service\AuthorizationService;
use Olcs\Controller\Mapper\CreateAccountMapper;
use Olcs\Controller\OperatorRegistrationController;
use Olcs\Session\ConsultantRegistration;
use Psr\Container\ContainerInterface;

class OperatorRegistrationControllerFactory implements FactoryInterface
Expand All @@ -27,7 +26,6 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$urlHelper = $container->get(UrlHelperService::class);
$flashMessengerHelper = $container->get(FlashMessengerHelperService::class);
$formatDataMapper = $container->get(CreateAccountMapper::class);
$consultantRegistrationSession = $container->get(ConsultantRegistration::class);

return new OperatorRegistrationController(
$niTextTranslationUtil,
Expand All @@ -37,8 +35,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$translationHelper,
$urlHelper,
$flashMessengerHelper,
$formatDataMapper,
$consultantRegistrationSession
$formatDataMapper
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
use LmcRbacMvc\Service\AuthorizationService;
use Olcs\Controller\Mapper\CreateAccountMapper;
use Olcs\Form\Model\Form\RegisterOperatorAccount;
use Olcs\Session\ConsultantRegistration;

class OperatorRegistrationController extends AbstractController
{
public function __construct(
NiTextTranslation $niTextTranslationUtil,
AuthorizationService $authService,
protected FormHelperService $formHelper,
protected ScriptFactory $scriptFactory,
protected TranslationHelperService $translationHelper,
protected UrlHelperService $urlHelper,
NiTextTranslation $niTextTranslationUtil,
AuthorizationService $authService,
protected FormHelperService $formHelper,
protected ScriptFactory $scriptFactory,
protected TranslationHelperService $translationHelper,
protected UrlHelperService $urlHelper,
protected FlashMessengerHelperService $flashMessengerHelper,
protected CreateAccountMapper $formatDataMapper,
protected ConsultantRegistration $consultantRegistrationSession
) {
protected CreateAccountMapper $formatDataMapper
)
{
parent::__construct($niTextTranslationUtil, $authService);
}

Expand All @@ -41,22 +40,16 @@ public function addAction(): Response|ViewModel
$form->setData($postData);
if ($form->isValid()) {
$formattedOperatorData = $this->formatDataMapper->formatSaveData($form->getData());
if (!$this->consultantRegistrationSession->getOperatorAdmin()) {
$formattedOperatorData['licenceNumber'] = $this->consultantRegistrationSession->getExistingLicence();
}

$response = $this->handleCommand(
RegisterUserSelfserve::create($formattedOperatorData)
);

if ($response->isOk()) {
if( !$this->consultantRegistrationSession->getOperatorAdmin()) {
return $this->redirect()->toRoute('user-registration/operator-confirm');
}
return $this->prepareView('olcs/user-registration/check-email', [
'emailAddress' => $formattedOperatorData['contactDetails']['emailAddress'],
'pageTitle' => 'user-registration.page.check-email.title'
]);

return $this->prepareView('olcs/user-registration/check-email', [
'emailAddress' => $formattedOperatorData['contactDetails']['emailAddress'],
'pageTitle' => 'user-registration.page.check-email.title'
]);
}

$this->flashMessengerHelper->addErrorMessage('There was an error registering your account. Please try again.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@
class UserRegistrationController extends AbstractController
{
public function __construct(
NiTextTranslation $niTextTranslationUtil,
AuthorizationService $authService,
protected FormHelperService $formHelper,
protected ScriptFactory $scriptFactory,
protected TranslationHelperService $translationHelper,
protected UrlHelperService $urlHelper,
NiTextTranslation $niTextTranslationUtil,
AuthorizationService $authService,
protected FormHelperService $formHelper,
protected ScriptFactory $scriptFactory,
protected TranslationHelperService $translationHelper,
protected UrlHelperService $urlHelper,
protected FlashMessengerHelperService $flashMessengerHelper,
protected CreateAccountMapper $formatDataMapper,
protected ConsultantRegistration $consultantRegistrationSession
) {
protected CreateAccountMapper $formatDataMapper,
protected ConsultantRegistration $consultantRegistrationSession
)
{
parent::__construct($niTextTranslationUtil, $authService);
}

Expand All @@ -46,19 +47,18 @@ public function __construct(
*/
public function startAction()
{
if($this->handleQuery(
if ($this->handleQuery(
IsEnabledQry::create(['ids' => [FeatureToggle::TRANSPORT_CONSULTANT_ROLE]])
)->getResult()['isEnabled']) {
// If the feature toggle is enabled, start the TC journey in new controller
return $this->forward()->dispatch(ConsultantRegistrationController::class, ['action' => 'add', 'params' => $this->params()->fromQuery()]);
return $this->forward()->dispatch(ConsultantRegistrationController::class, ['action' => 'add', 'params' => $this->params()->fromQuery()]);
} else {
// If disabled, start the normal add journey in this controller
return $this->forward()->dispatch(static::class, ['action' => 'add']);
}
}



/**
* Method used for the registration form page
*
Expand Down Expand Up @@ -120,14 +120,19 @@ protected function alterForm(Form $form)

$termsAgreed->setLabel($label);

if ($this->consultantRegistrationSession->getOperatorAdmin() === false) {
$form->get('fields')->get('licenceNumber')->setValue($this->consultantRegistrationSession->getExistingLicence())->setAttribute('type', 'hidden');
$form->get('fields')->get('isLicenceHolder')->setValue('Y')->setAttribute('type', 'hidden');
$form->get('fields')->get('isLicenceHolder')->setLabel('');
}
return $form;
}

/**
* Generate content for user registration
*
* @param array $formData Form data
* @param array $errors Errors from ZF Validation Chain
* @param array $errors Errors from ZF Validation Chain
*
* @return ViewModel
*/
Expand Down Expand Up @@ -161,6 +166,7 @@ private function generateContentForUserRegistration(array $formData = [], array

return $view;
}

public function operatorConfirmAction(): ViewModel
{
$existingLicence = $this->consultantRegistrationSession->getExistingLicence();
Expand All @@ -171,6 +177,7 @@ public function operatorConfirmAction(): ViewModel
]
]);
}

/**
* Process user registration form data
*
Expand Down Expand Up @@ -248,6 +255,7 @@ private function showLicence($formData)
];
}


return $this->generateContentForUserRegistration($formData, $errors);
}

Expand Down

0 comments on commit d5ec492

Please sign in to comment.