Last active
August 29, 2015 14:22
-
-
Save psamatt/e36bfc6d9fda091c79ef to your computer and use it in GitHub Desktop.
Process of a teacher email students
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 Lecture extends EventSourcedAggregateRoot | |
{ | |
public function __construct(LectureId $id, StartTime $startTime) { | |
} | |
public function remindStudents() | |
{ | |
$this->guardNotLAstDay(); | |
$this->apply(TeacherRequestedReminderForLecture($lectureId, $teacherId, $studentIds)) | |
} | |
} |
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 TeacherRequestsReminderForLecture { | |
public function __construct(TeacherId $teacherId, LectureId $lectureId) {} | |
} | |
class LectureCommandHandler { | |
function handleTeacherRequestsReminderForLecture(TeacherRequestsReminderForLecture $cmd) | |
{ | |
$lecture = $this->repo->find($cmd->lectureId); | |
$lecture->remindStudents(); | |
} | |
} |
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 LectureProcessor | |
{ | |
public function whenTeacherRequestedReminderForLecture(TeacherRequestedReminderForLecture $event) | |
{ | |
foreach($event->studentIds as $studentId) { | |
$this->emailer->remindStudent($studentId, $lectureId); | |
$this->commandBus->dispatch(RemindStudentOfLecture($studentId, $lectureId)); | |
} | |
} | |
} |
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 StudentCommandHandler | |
{ | |
public function handleRemindStudentOfLecture(RemindStudentOfLecture $cmd) | |
{ | |
student = $this->repo->find($cmd->studentId); | |
student->remind($lectureId); | |
} | |
} | |
class Student{ | |
public function remind($lectureId) { | |
apply(StudentRemindedOfLecture($studentId, $lectureId)); | |
} | |
} | |
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 StudentReminderProjector { | |
public function whenStudentRemindedOfLecture() { | |
// update view model | |
} | |
} |
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
// command | |
class TeacherRequestsReminderForLecture { | |
public function __construct(LectureId $lectureId, TeacherId $teacherId) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment