dto - How to separate business logic from an entity in Symfony -


first of don't know if title clear , in fact not words.

i work on "simple" project in company: build checkout few screens: offers, login, register, forgot password, user informations, confirmation. have 1 mouth.

we 3 developers in project. 2 juniors included me , 1 lead developer.

the lead developer said wants "separate business logic entities". "if don't end big entity future needs, , doctrine manager it". user entity implements serializable interface , referring user properties bypassing doctrine reference. mention dto lot of time , search , not understand particular thing.

so instead of creating user entity classic way (doctrine mapping, validator assertions), creates 2 classes.

a "model" user class represent user inputs validator annotations and, next pass data service call setters on user class entity , persist it.

note "model" user class not in classic entity namespace, , yes matter classic behavior of symfony , doctrine orm go pick annotation / mapping information , other stuff).

he asks me write unit test , functional test around user registration. after couple assertions try retrieve validator metadata check if respected. more precise, validator errors messages.

but evaluations of uniqueentity annotation don't work , indicate object manager can't found object (remember puts assertions in "model" user , not entity one), indicate "entityclass (https://symfony.com/doc/current/reference/constraints/uniqueentity.html#entityclass)" value pointing entity one

i try present facts , not including judgement , toughs.

i think still can use propertyinfo component access annotations, try tomorrow.

but think of ? think of implementation ?

to sure question not marked not pertinent stackoverflow, can ask: what's best way separate business logic entities in symfony project?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -