sfPropelObjectPathBehaviorPlugin
Introduction
This plugin adds ObjectPath support to Propel (1.5+).
This syntax makes it very easy to do sorting and filtering on foreign fields.
ObjectPaths are dot-seperated relation-names that relate from one object to another and this behavior translates the objectPaths to table-aliasses.
Example
So a very simple ObjectPath from City to Country is simply "Country" and from Country to City it would be "City":
In other words the relation-name.
However ObjectPaths support dots to 'jump' from object to object. So for example from Review to Book to Author would be "Book.Author".
In Php-code this shows up as:
$query = new ReviewQuery();
$reviews = $query->
joinByObjectPath('Book.Author')->
orderBy('Book.Author.FirstName', Criteria::ASC)->
find();
to find all reviews, joined with their Books, joined with their Authors.
TODO: explain all changes and the behavior in more detail
Installation
To install this plugin you need to checkout this code in your symfony plugins folder under sfPropelObjectPathBehaviorPlugin
After the checkout, modify your project/config/propel.ini
add
propel.behavior.object_path.class = plugins.sfPropelObjectPathBehaviorPlugin.lib.ObjectPathBehavior
and add the default behavior, by modifying
propel.behavior.default = symfony,symfony_i18n,object_path
now rebuild your model and you are good to go!
$ php symfony propel:build-model
Note
The objectPathsBehavior is used in the sfDataSourcePlugin.