On Github Ocramius / ShittyCQRSPresentation
The end
class ContractController {
public function putAction()
{
// validation
$contract = $this->contracts->find($data['id']);
// update the contract with data
$this->contractService->save($contract);
return $renderTemplate($contract);
}
}
class ContractController {
public function putAction()
{
// validation
$contract = $this->contracts->find($data['id']);
// update the contract with data
$this->contractService->save($contract);
return $renderTemplate($contract);
}
}
$command = new TerminateContract($contractId); execute($command);
$contractsArchive->find($contractId);
class ContractController {
public function terminateContractAction()
{
$commandBus(new TerminateContract($data['id']));
return $renderTemplate($contracts->findById($data['id']));
}
}$commandHandler = function (TerminateContract $terminate) use (...) {
$contract = $contracts->find($terminate->contractId);
$contract->terminate();
$registerEvent(new ContractWasTerminated($contract->id));
$save($contract);
$commandBus(new SendCancellationNotifications($contract->id));
};With @malukenho