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
class ChangeEmailAddressCommand | |
{ | |
public function __construct(private string $userId, private string $email) {} | |
public function getUserId(): string | |
{ | |
return $this->userId; | |
} | |
public function getEmail(): string |
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
class UserService | |
{ | |
#[CommandHandler] | |
public function changeEmail(ChangeEmailAddressCommand $command) : void | |
{ | |
// retrieve user and change the email | |
} | |
} |
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
<?php | |
class PersonController | |
{ | |
public function __construct(private CommandBus $commandBus) {} | |
public function changeEmailAddress(Request $request) | |
{ | |
$userId = $request->get('userId'); | |
$email = $request->get('email'); | |
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
<?php | |
class GetUserShippingAddressQuery | |
{ | |
public function __construct(private string $userId) {} | |
public function getUserId(): string | |
{ | |
return $this->userId; | |
} | |
} |
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
<?php | |
class UserService | |
{ | |
#[QueryHandler] | |
public function getPersonDetails(GetUserShippingAddressQuery $query) | |
{ | |
$shippingAddress = // use query to get the shipping address; | |
return $shippingAddress; | |
} |
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
<?php | |
class PersonController | |
{ | |
public function __construct(private QueryBus $queryBus) {} | |
public function getShippingAddress(Request $request) | |
{ | |
$userId = $request->get('userId'); |
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
<?php | |
class PersonWasRegistered | |
{ | |
public function __construct(private string $personId) {} | |
public function getPersonId(): string | |
{ | |
return $this->personId; | |
} | |
} |
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
<?php | |
class PersonRegistrationEventSubscriber | |
{ | |
#[EventHandler] | |
public function sendWelcomeEmail(PersonWasRegistered $event, EmailSender $emailSender): void | |
{ | |
$person = $this->userRepository->getById($event->getPersonId()); | |
$emailSender->sendWelcomeTo($person); | |
} |
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
<?php | |
use Ecotone\Modelling\EventBus; | |
class PersonRegistrationService | |
{ | |
public function __construct(private UserRepository $userRepository, private EventBus $event) {} | |
public function registerUser($registerPersonData) | |
{ |
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
<?php | |
class PersonRegistrationService | |
{ | |
public function __construct(private UserRepository $userRepository, private EmailSender $emailSender, private LogRepository $logRepository, private ExternalIntegratedService $externalService) {} | |
public function registerUser($registerPersonData) | |
{ | |
$person = new Person($registerPersonData); | |
$this->userRepository->save($person); |
OlderNewer