-
Notifications
You must be signed in to change notification settings - Fork 27
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
Get model class from entity #59
Comments
Entity instances are database agnostic. With Pomm, it is possible to have multiple Model class to hydrate the same entity class (useful to manage users, operators, administrators by example). This said, you are pointing at a problem in the actual model manager: there is no way to know at least what model class has created an entity (if that happened). Implementing a signature in the entities would make your Validator to know which model class to use to call the built in Would that be a solution to your problem? |
I have solved my problem with a custom ModelClassResolver which resolve the model class from an entity class. I already think that it will be great if the model manager could provide the model class from an entity. |
Is it possible to have a look at the |
It's a very simple service ... In my model classes i have set the entity class as a constant. |
I think I will go for the signature idea. All model class sign the entity they create or fetch. It might be interesting to do that in the identity mapper to prevent it to return the same entity when two different model classes (with different projection) do query the same entities. Thank you very much for your report 👍 |
Your idea is to add a The model can call it on entity creation, but the Must we inject the |
I would like to get the model class from a flexible entity instance ...
Is there a simple way to do this ?
I need this for my custom UniqueFlexibleEntityValidator which validate that a database record doesn't exists for a field set (like a slug).
It is what the DoctrrineUniqueEntityValidator does (@see https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php).
I need to access to the model class from the flexible entity instance in the validation process (to test uniqueness).
I can add a custom constant (MODEL_CLASS) in my flexible entity class but it is not optimized ...
Thanks
The text was updated successfully, but these errors were encountered: