- Either clone the repository or download the behavior and copy instantiable.php to app/models/behaviors/
- Next either add the behavior to the app_model or to each model you would like to use it in. $ var $actAs = array('Instantiable');
To have a call to find return model objects instead just add 'Instantiable' => true to the parameters: $ $this->User->find('first', array('Instantiable' => true));
If you would like every call to find to return model objects just add the alwaysInstantiate value when you add the behavior like so: $ var $actAs = array('Instantiable' => array('alwaysInstantiate' => true)); Note: This will likely cause issues if you have baked your views since they will be looking for a data array instead of a model object.
Then given a user model who's normal data from this find:
$
Now you can do the following:
$ $user =