Skip to content

Commit

Permalink
feat: VOL-5239 create transport consultant reg journey
Browse files Browse the repository at this point in the history
  • Loading branch information
ilindsay authored and fibble committed Aug 22, 2024
1 parent 64c5c3c commit 82ed46c
Show file tree
Hide file tree
Showing 22 changed files with 885 additions and 36 deletions.
1 change: 1 addition & 0 deletions app/api/module/Api/config/command-map.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@
TransferCommand\User\UpdatePartner::class => CommandHandler\User\UpdatePartner::class,
TransferCommand\User\DeletePartner::class => CommandHandler\User\DeletePartner::class,
TransferCommand\User\UpdateUserLastLoginAt::class => CommandHandler\User\UpdateUserLastLoginAt::class,
TransferCommand\User\RegisterConsultantAndOperator::class => CommandHandler\User\RegisterConsultantAndOperator::class,

// Transfer - Team
TransferCommand\Team\CreateTeam::class => CommandHandler\Team\CreateTeam::class,
Expand Down
1 change: 1 addition & 0 deletions app/api/module/Api/config/validation-map/user.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CommandHandler\User\RegisterUserSelfserve::class => NoValidationRequired::class,
CommandHandler\User\RegisterUserSelfserveFactory::class => NoValidationRequired::class,
CommandHandler\User\RemindUsernameSelfserve::class => NoValidationRequired::class,
CommandHandler\User\RegisterConsultantAndOperator::class => NoValidationRequired::class,
CommandHandler\User\UpdatePartner::class => IsInternalUser::class,
CommandHandler\User\CreateUserSelfserve::class => CanManageUser::class,
CommandHandler\User\CreateUserSelfServeFactory::class => CanManageUser::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* Register User Selfserve
*/

namespace Dvsa\Olcs\Api\Domain\CommandHandler\User;


use Dvsa\Olcs\Api\Domain\Command\Result;
use Dvsa\Olcs\Api\Domain\CommandHandler\AbstractUserCommandHandler;
use Dvsa\Olcs\Api\Domain\CommandHandler\TransactionedInterface;
use Dvsa\Olcs\Transfer\Command\CommandInterface;
use Dvsa\Olcs\Transfer\Command\User\RegisterConsultantAndOperator as RegisterConsultantAndOperatorCommand;
use Dvsa\Olcs\Transfer\Command\User\RegisterUserSelfserve as RegisterUserSelfServeCommand;

/**
* Register User Selfserve
*/
final class RegisterConsultantAndOperator extends AbstractUserCommandHandler implements
TransactionedInterface
{
protected $repoServiceName = 'User';

public function handleCommand(CommandInterface $command)
{
assert($command instanceof RegisterConsultantAndOperatorCommand);
// Register the operator first, a new Org will be created.
$result = $this->handleSideEffect(RegisterUserSelfServeCommand::create($command->getOperatorDetails()));

// Get the newly created user entity
$user = $this->getRepo()->fetchById($result->getId('user'));

// Add the org ID of the newly created user/org to the consultant details, then register the consultant
$consultantDetails = $command->getConsultantDetails();
$consultantDetails['organisation'] = $user->getOrganisationUsers()->first()->getOrganisation()->getId();

$result2 = $this->handleSideEffect(RegisterUserSelfServeCommand::create($consultantDetails));

return new Result();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function handleCommand(CommandInterface $command)
} elseif (!empty($data['organisationName'])) {
// create organisation and link with it
$data['organisations'] = [$this->createOrganisation($data)];
} elseif (!empty($data['organisation'])) {
// link with the organisation
$data['organisations'] = [$this->getRepo('Organisation')->fetchById($data['organisation'])];
}

if (empty($data['organisations'])) {
Expand Down
58 changes: 54 additions & 4 deletions app/selfserve/module/Olcs/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,50 @@
'route' => '/register[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'add'
'action' => 'start'
]
],
'may_terminate' => true,
'child_routes' => [
'operator' => [
'type' => 'segment',
'options' => [
'route' => 'operator[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'add'
]
]
],
'operator-representation' => [
'type' => 'segment',
'options' => [
'route' => 'operator-representation[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'operatorRepresentation'
]
]
],
'register-for-operator' => [
'type' => 'segment',
'options' => [
'route' => 'register-for-operator[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'registerForOperator'
]
]
],
'register-consultant-account' => [
'type' => 'segment',
'options' => [
'route' => 'register-consultant-account[/]',
'defaults' => [
'controller' => UserRegistrationController::class,
'action' => 'registerConsultantAccount'
]
]
]
]
],
Expand Down Expand Up @@ -1434,7 +1477,9 @@
'CookieSettingsCookieNamesProvider' => CookieService\SettingsCookieNamesProvider::class,
'QaIrhpApplicationViewGenerator' => QaService\ViewGenerator\IrhpApplicationViewGenerator::class,
'QaIrhpPermitApplicationViewGenerator' => QaService\ViewGenerator\IrhpPermitApplicationViewGenerator::class,
LicenceVehicleManagement::class => LicenceVehicleManagement::class
LicenceVehicleManagement::class => LicenceVehicleManagement::class,
\Olcs\Session\ConsultantRegistration::class => \Olcs\Session\ConsultantRegistration::class,

],
'abstract_factories' => [
\Laminas\Cache\Service\StorageCacheAbstractServiceFactory::class,
Expand Down Expand Up @@ -1668,7 +1713,7 @@
'verify/process-response' => ['*'],
'search*' => ['*'],
'index' => ['*'],
'user-registration' => ['*'],
'user-registration*' => ['*'],
'user-forgot-username' => ['*'],
'cookies*' => ['*'],
'privacy-notice' => ['*'],
Expand Down Expand Up @@ -1701,5 +1746,10 @@
'options_default_plus_cancel' => \Permits\Form\Model\Fieldset\SubmitOrCancelApplication::class,
'options_bilateral' => \Permits\Form\Model\Fieldset\SubmitOnly::class,
]
]
],
'validators' => [
'factories' => [
\Olcs\Form\Validator\UniqueConsultantDetails::class => \Olcs\Form\Validator\Factory\UniqueConsultantDetailsFactory::class,
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Common\Service\Helper\UrlHelperService;
use Common\Service\Script\ScriptFactory;
use Dvsa\Olcs\Utils\Translation\NiTextTranslation;
use Olcs\Session\ConsultantRegistration;
use Psr\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Olcs\Controller\UserRegistrationController;
Expand All @@ -30,6 +31,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$translationHelper = $container->get(TranslationHelperService::class);
$urlHelper = $container->get(UrlHelperService::class);
$flashMessengerHelper = $container->get(FlashMessengerHelperService::class);
$consultantRegistrationSession = $container->get(ConsultantRegistration::class);

return new UserRegistrationController(
$niTextTranslationUtil,
Expand All @@ -38,7 +40,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$scriptFactory,
$translationHelper,
$urlHelper,
$flashMessengerHelper
$flashMessengerHelper,
$consultantRegistrationSession
);
}
}
Loading

0 comments on commit 82ed46c

Please sign in to comment.