symfony - Is there a way to set a Doctrine Event Listener that limits every entity query to a specific field id? -
setting doctrine event listeners persisting , updating entities extremely useful feature. appears limited update
or insert
statements. select
queries?
let's have hosted cms shared database every record has siteid
denoting record belongs site. when search records (entities) display on given site, need limit results records specific siteid
. manually limit every single query in code, has potential forgetting (which security issue). considering making automatic every single query (i may need override in instances).
so can manipulate dql or querybuilder in sort of preselect
event listener makes sure limit siteid?
and if so, ideally overwrite in system administrative interfaces want find records regardless of siteid.
is possible? bad idea? smell rosemary?
take @ doctrine filters
.
doctrine2 - there pre-selection hook?
http://docs.doctrine-project.org/en/latest/reference/filters.html
doctrine 2.2 features filter system allows developer add sql conditional clauses of queries, regardless place sql generated (e.g. dql query, or loading associated entities).
the filter functionality works on sql level. whether sql query generated in persister, during lazy loading, in lazy collections or dql. each time system iterates on enabled filters, adding new sql part filter returns.
by adding sql conditional clauses of queries, filter system filters out rows belonging entities @ level of sql result set. means filtered entities never hydrated (which can expensive).
Comments
Post a Comment