public final function __construct($data = [], $dependencyInjector = null)
{
$this->_dependencyInjector = $dependencyInjector ?: FactoryDefault::getDefault();
$modelName = get_class($this);
if (!isset(self::$_initialized[$modelName])) {
if (method_exists($this, 'initialize')) {
$this->initialize();
}
self::$_initialized[$modelName] = true;
}
/**
* This allows the developer to execute initialization stuff every time an instance is created
*/
if (method_exists($this, 'onConstruct')) {
$this->onConstruct();
}
if (count($data) !== 0) {
$this->_snapshot = $data;
foreach ($data as $attribute => $value) {
$this->{$attribute} = $value;
}
if (method_exists($this, 'afterFetch')) {
$this->afterFetch();
}
}
}