Sylius: Form DTO for ResourceBundle

Created on 19 Jul 2018  路  2Comments  路  Source: Sylius/Sylius

I'm very sad any times i make some entity with alway support null argument and return value for all properties.

eg.

public function setCode(?string $code): void;
public function getCode(): ?string;

But code can't be null in both Business and DB layer.

<field name="code" type="string" length="10" unique="true" nullable="false"/>

Then it should be:

public function setCode(string $code): void;
public function getCode(): string;

We need DTO so much, for more detail here is related posts.

https://stovepipe.systems/post/avoiding-entities-in-forms
https://blog.martinhujer.cz/symfony-forms-with-request-objects/

RFC Stale

Most helpful comment

The overall plan for the 2.0 version includes introducing Command and Query objects being the only entry points in the application. We will also try to make our models always valid, but that's a little bit more difficult actually (Matthias Noback wrote a good blog post about it a few days ago: https://matthiasnoback.nl/2018/07/objects-should-be-constructed-in-one-go/).

All 2 comments

The overall plan for the 2.0 version includes introducing Command and Query objects being the only entry points in the application. We will also try to make our models always valid, but that's a little bit more difficult actually (Matthias Noback wrote a good blog post about it a few days ago: https://matthiasnoback.nl/2018/07/objects-should-be-constructed-in-one-go/).

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings