zfcampus / zf-doctrine-querybuilder

Doctrine Query Builder request Filters
BSD 3-Clause "New" or "Revised" License
32 stars 19 forks source link

Get metadata for specific entity class when creating query. #29

Closed matwright closed 8 years ago

matwright commented 8 years ago

Currently when fetching meta data for an ODM entity the method createQuery() uses the getAllMetadata() methods from the MetadataFactory object and then opts to use the first key (0) as the mapping to be passed to the filter manager. However the first key doesn't necessarily hold the correct mapping data. For example if an entity extends an abstract class then the abstract class meta data will be returned. This leads to fieldMappings being absent from computation in the filter.

A good example is the typeCaseField method which uses a try/catch switch to determine the type, however when the entity extends other classes as per my example above, then the fieldMappings for the given field aren't necessarily in the meta data (for example they are only declared in the entity and not the extended classes).

I propose to use the getMetadataFor() methods of the metadataFactory class to fetch specific meta data for the given entity class.

https://github.com/zfcampus/zf-doctrine-querybuilder/pull/29/files

brunoMaurice commented 8 years ago

+1 I asked to change the readme for this on PR #28