protected static function _initialize($class)
{
$self = static::$_instances[$class];
if (isset(static::$_initialized[$class]) && static::$_initialized[$class]) {
return $self;
}
static::$_initialized[$class] = true;
$self->_inherit();
$source = array('classes' => array(), 'meta' => array(), 'finders' => array(), 'schema' => array());
$meta = $self->_meta;
if ($meta['connection']) {
$classes = $self->_classes;
$conn = $classes['connections']::get($meta['connection']);
$source = ($conn ? $conn->configureClass($class) : array()) + $source;
}
$self->_classes += $source['classes'];
$self->_meta = compact('class') + $self->_meta + $source['meta'];
$self->_initializers += array('name' => function ($self) {
return basename(str_replace('\\', '/', $self));
}, 'source' => function ($self) {
return Inflector::tableize($self::meta('name'));
}, 'title' => function ($self) {
$titleKeys = array('title', 'name');
$titleKeys = array_merge($titleKeys, (array) $self::meta('key'));
return $self::hasField($titleKeys);
});
if (is_object($self->_schema)) {
$self->_schema->append($source['schema']);
} else {
$self->_schema += $source['schema'];
}
$self->_finders += $source['finders'] + static::_finders();
$self->_classes += array('query' => 'lithium\\data\\model\\Query', 'validator' => 'lithium\\util\\Validator', 'entity' => 'lithium\\data\\Entity');
static::_relationsToLoad();
return $self;
}