lithium\data\Model::_initialize PHP Method

_initialize() protected static method

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
protected static _initialize ( string $class ) : object
$class string The fully-namespaced class name to initialize.
return object Returns the initialized model instance.
    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;
    }