UnionOfRAD/lithium — pull request #609 by jails (2012-08-09 18:52:07+00:00)
Title: Lazily initialize Model's metadata, refactor Model::_init() and Model::_classes is no more static

1 - Implementing the @nateabele Model's metadatas initializations strategy using cutom closures.

Example :

```
Posts::config(array(
'initializers' => array(
'source' => function(&$meta) {
if ($meta['source'] === null) {
$meta['source'] = 'custom_posts';
}
},
'custom' => function(&$meta) {
$meta['custom'] = 'custom_data';
}
)
));
```

2 - Model::_classes is no more static.

3 - Since Models are in the "same time" static and dynamic, for consistency, this PR reintroduce the `_init()` method which is a standard method called just after `__construct`.
Here `_init()` is called just after the class instanciation (instead of `__construct`) and can be used for lazy initializations.
`__init()` can always be used for "direct" initializations.

PS:
`__init()` is a static function called during the autoload step. using `parent::__init()` will result to call the parent's `__init()` **twice**. So in li3 `parent::__init()` is an invalid syntax and shouldn't be used.