Extends
lithium\core\StaticObject
Configures the model for use. This method is called by `Model::__init()`.
This method will set the `Model::$_schema`, `Model::$_meta`, `Model::$_finders` class
attributes, as well as obtain a handle to the configured persistent storage connection.
Parameters
- array $options Possible options are: - `meta`: Meta-information for this model, such as the connection. - `finders`: Custom finders for this model.
Returns
voidSource
public static function config(array $options = array()) {
if (static::_isBase($class = get_called_class())) {
return;
}
$self = static::_object();
$query = array();
$meta = array();
$schema = array();
$source = array();
$classes = static::$_classes;
foreach (static::_parents() as $parent) {
$parentConfig = get_class_vars($parent);
foreach (array('meta', 'schema', 'classes', 'query') as $key) {
if (isset($parentConfig["_{$key}"])) {
${$key} += $parentConfig["_{$key}"];
}
}
if ($parent == __CLASS__) {
break;
}
}
$tmp = $options + $self->_meta + $meta;
$source = array('meta' => array(), 'finders' => array(), 'schema' => array());
if ($tmp['connection']) {
$conn = $classes['connections']::get($tmp['connection']);
$source = (($conn) ? $conn->configureClass($class) : array()) + $source;
}
static::$_classes = $classes;
$name = static::_name();
$local = compact('class', 'name') + $options + $self->_meta;
$self->_meta = ($local + $source['meta'] + $meta);
$self->_meta['initialized'] = false;
$self->_schema += $schema + $source['schema'];
$self->_finders += $source['finders'] + $self->_findFilters();
static::_relations();
}