UnionOfRAD/lithium — pull request #886 by jails (2013-04-15 12:12:52+00:00)
Title: Relations can be retrived by the relation name or its corresponding field name.

Consolidate `Model::relations()` to alos accept a field name as parameter.

Currently all model relations own a `'fieldName'` attribute used to format datas. For example for a Post hasMany Comment, comments will "appear" in a `comments` attribute:

```php
print_r($post->comments->data());
```php

With this PR:

```php
Model::relations('Comment'); // return the Comment relation
Model::relations('comments'); // return the Comment relation
```

To keep the lazy loading works, I removed the field name generation from the `Relationship` class.

By default the default field name generation is delegated to the datasource. This mean `Database` compatible source will return underscored field names and mongo camelBack field names (Maybe we can provide some consistency here).

Anyway, is you are like me not a big fan of underscored, pluralization, camelBack, etc. You can provide you own fieldname convention by overriding the `Model::_fieldName()` methods.

For example the "CakePHP" way can be obtained by overriding the `Model::_fieldName()` with:

```php
protected function _fieldName($type, $name) {
return $name;
}
```