-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: VOL-5239 create transport consultant reg journey
- Loading branch information
Showing
22 changed files
with
885 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/api/module/Api/src/Domain/CommandHandler/User/RegisterConsultantAndOperator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.