Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course creator use case #15

Merged

Conversation

mangelsnc
Copy link
Contributor

No description provided.

Copy link
Member

@JavierCane JavierCane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good work @mangelsnc!

Some feedback provided. Take special attention to the comment with the ⚠️ emoji. 🙂


codely.api.controller.course.post:
class: CodelyTv\Api\Controller\Course\CoursePostController
parent: codely.api.controller
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line at the end of files by default please 🙏

You can enable it in PhpStorm / IntelliJ:

preferences 2017-10-13 12-35-54

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip!

@@ -2,3 +2,4 @@ imports:

- { resource: status.yml }
- { resource: video.yml }
- { resource: course.yml }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏👏👏

use CodelyTv\Types\ValueObject\Uuid;
use Symfony\Component\HttpFoundation\Request;

final class CoursePostController extends ApiController
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏👏👏


public function create(CourseId $id, CourseTitle $title, CourseDescription $description)
{
$course = new Course($id, $title, $description);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use a named constructor as in https://github.com/CodelyTV/cqrs-ddd-php-example/blob/d3da9074b765d0612e4c467e54d0cac94ba7d7c9/src/Context/Video/Module/Video/Application/Create/VideoCreator.php#L26

Why: https://codely.tv/screencasts/constructores-semanticos/ + record events inside the named constructor leaving the default constructor for reconstructing Video instances in a certain state without recording these events.

{
parent::__construct($messageId);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary 2 blank lines 🙂


final class CourseCreatedDomainEvent extends DomainEvent
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank line 🙂


final class CourseRepositoryMySql extends Repository implements CourseRepository
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary blank line

final class CourseRepositoryMySql extends Repository implements CourseRepository
{

public function save(Course $course)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return type (: void) in order to make the side effect more explicit.


$this->repository->save($course);

$this->publisher->publish(...$course->pullDomainEvents());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

$this->publisher = $publisher;
}

public function create(CourseId $id, CourseTitle $title, CourseDescription $description)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add return type (: void) in order to make the side effect more explicit.

@rgomezcasas rgomezcasas changed the base branch from master to mangelsnc-merge January 11, 2018 20:59
@rgomezcasas rgomezcasas merged commit cbcc96a into CodelyTV:mangelsnc-merge Jan 11, 2018
@rgomezcasas
Copy link
Member

@mangelsnc I merged it with a minor changes. Also I created an issue (#24) in order to add some missing things 😋

If you want to solve that issue feel free!! 😬

@rgomezcasas
Copy link
Member

Also, @mangelsnc you're our first external contributor (https://github.com/CodelyTV/cqrs-ddd-php-example/graphs/contributors)!! 🎉🎉🎊🎊

@mangelsnc
Copy link
Contributor Author

Cool! I will take a look at the issue! 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants