{"action":"created","issue":{"url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/22","labels_url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/22/comments","events_url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/22/events","html_url":"https://github.com/javiereguiluz/EasyAdminBundle/issues/22","id":54632486,"number":22,"title":"Allow to pass arguments to entity constructors","user":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/labels/enhancement","name":"enhancement","color":"00994D"},{"url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/labels/future","name":"future","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-16T22:23:51Z","updated_at":"2015-01-16T23:43:25Z","closed_at":null,"body":"Right now, when creating a new entity, we just use this trivial code:\r\n\r\n```php\r\n$entityFullyQualifiedClassName = $this->entity['class'];\r\n$item = new $entityFullyQualifiedClassName();\r\n```\r\n\r\nAs @stof correctly pointed in [this comment](https://github.com/javiereguiluz/EasyAdminBundle/commit/f08250a85b35e5f71603e04ff614e8a79040fe1d#commitcomment-9314005) this code prevents to pass arguments to entity constructors in order to properly initialize them.\r\n\r\nI don't know how often do developers pass arguments to entities, so I'm going to think about this. In any case, we probably can use the simple solution suggested by @stof: create a new `protected` method that initializes the entities, allowing developers to override that method to suit their needs."},"comment":{"url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/comments/70340775","html_url":"https://github.com/javiereguiluz/EasyAdminBundle/issues/22#issuecomment-70340775","issue_url":"https://api.github.com/repos/javiereguiluz/EasyAdminBundle/issues/22","id":70340775,"user":{"login":"Pierstoval","id":3369266,"avatar_url":"https://avatars.githubusercontent.com/u/3369266?v=3","gravatar_id":"","url":"https://api.github.com/users/Pierstoval","html_url":"https://github.com/Pierstoval","followers_url":"https://api.github.com/users/Pierstoval/followers","following_url":"https://api.github.com/users/Pierstoval/following{/other_user}","gists_url":"https://api.github.com/users/Pierstoval/gists{/gist_id}","starred_url":"https://api.github.com/users/Pierstoval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pierstoval/subscriptions","organizations_url":"https://api.github.com/users/Pierstoval/orgs","repos_url":"https://api.github.com/users/Pierstoval/repos","events_url":"https://api.github.com/users/Pierstoval/events{/privacy}","received_events_url":"https://api.github.com/users/Pierstoval/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T23:43:25Z","updated_at":"2015-01-16T23:43:25Z","body":"Why don't you create a service tag to allow end user to manipulate the entity during the process of creation/edition ? Like using `constructEntity` and some more methods like prePersist or postPersist, etc. "}}