{"action":"created","issue":{"url":"https://api.github.com/repos/neos/flow-development-collection/issues/112","repository_url":"https://api.github.com/repos/neos/flow-development-collection","labels_url":"https://api.github.com/repos/neos/flow-development-collection/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/neos/flow-development-collection/issues/112/comments","events_url":"https://api.github.com/repos/neos/flow-development-collection/issues/112/events","html_url":"https://github.com/neos/flow-development-collection/pull/112","id":113837376,"number":112,"title":"FEATURE: Make ObjectAccess use add/remove methods on collection types","user":{"login":"albe","id":4259532,"avatar_url":"https://avatars.githubusercontent.com/u/4259532?v=3","gravatar_id":"","url":"https://api.github.com/users/albe","html_url":"https://github.com/albe","followers_url":"https://api.github.com/users/albe/followers","following_url":"https://api.github.com/users/albe/following{/other_user}","gists_url":"https://api.github.com/users/albe/gists{/gist_id}","starred_url":"https://api.github.com/users/albe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albe/subscriptions","organizations_url":"https://api.github.com/users/albe/orgs","repos_url":"https://api.github.com/users/albe/repos","events_url":"https://api.github.com/users/albe/events{/privacy}","received_events_url":"https://api.github.com/users/albe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/neos/flow-development-collection/labels/P:%20Flow","name":"P: Flow","color":"0052cc"},{"url":"https://api.github.com/repos/neos/flow-development-collection/labels/T:%20PHP","name":"T: PHP","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-10-28T14:44:34Z","updated_at":"2016-05-04T20:23:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/neos/flow-development-collection/pulls/112","html_url":"https://github.com/neos/flow-development-collection/pull/112","diff_url":"https://github.com/neos/flow-development-collection/pull/112.diff","patch_url":"https://github.com/neos/flow-development-collection/pull/112.patch"},"body":"This change will make ObjectAccess use dedicated add*/remove* methods on all collection type\r\nproperties if available, instead of always depending on setting the whole collection property\r\nat once.\r\n\r\nThis is necessary for following use cases:\r\n- you want to add/remove items on the inverse side of a doctrine relation (i.e. the \"one\" side of a OneToMany relation)\r\n- you want to remove items from a collection via web form and have special handling code in the remove* method\r\n- you want to track entity changes by logging accesses to add/remove methods\r\n- you have special domain rules for a collection property that are enforced per single item removal/addition\r\n- you want to prevent other models from completely overwriting a collection property on your entity (no need for set* collection setter)\r\n\r\nThis will allow a more clean domain modelling with clear change rules on collection properties\r\nand enforce those rules within property mapping and your domain model.\r\n\r\nFLOW-366 #close"},"comment":{"url":"https://api.github.com/repos/neos/flow-development-collection/issues/comments/216991429","html_url":"https://github.com/neos/flow-development-collection/pull/112#issuecomment-216991429","issue_url":"https://api.github.com/repos/neos/flow-development-collection/issues/112","id":216991429,"user":{"login":"albe","id":4259532,"avatar_url":"https://avatars.githubusercontent.com/u/4259532?v=3","gravatar_id":"","url":"https://api.github.com/users/albe","html_url":"https://github.com/albe","followers_url":"https://api.github.com/users/albe/followers","following_url":"https://api.github.com/users/albe/following{/other_user}","gists_url":"https://api.github.com/users/albe/gists{/gist_id}","starred_url":"https://api.github.com/users/albe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albe/subscriptions","organizations_url":"https://api.github.com/users/albe/orgs","repos_url":"https://api.github.com/users/albe/repos","events_url":"https://api.github.com/users/albe/events{/privacy}","received_events_url":"https://api.github.com/users/albe/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T20:23:12Z","updated_at":"2016-05-04T20:23:12Z","body":"> So lets get back to the core of the original issue:\r\n\r\nSure.\r\n\r\n> We want to make it easier to work entities that have OneToMany & ManyToMany relations in web forms.\r\n\r\nNot only in web forms, but that's the most common (probably 95%+) use case, yes.\r\n\r\nThe most problematic issue with this is dealing with OneToMany relations on entities, where it's currently not possible to remove items by submitting the *One* side without adding a lot of boilerplate code in the controller. For doctrine the *Many* side is always the owning side of such a relation, therefore to remove an item one has to either submit the removed item(s) seperately (imagine the javascript code for that) and manually update the relation on each, or fetch the original persisted *One* item, iterate all related items and find the ones that are currently missing.\r\nBtw. the same would apply also without doctrine and a simple DTO, where you would not be able to do anything on/for removed items, like log them, derive essential business intel from it or just have a business rule apply to maybe not remove items of a specific type under some circumstances - in essence you lose change information unless you work around that information loss.\r\n\r\nBy making Flow follow add/remove semantics, you can put any such logic into those methods, where it belongs.\r\n"}}