public function get($property, $default = null, $modelName = null)
{
// If $model is null we use the default model
if (is_null($modelName)) {
$model = $this->defaultModel;
} else {
$model = $modelName;
}
// First check to make sure the model requested exists
if (isset($this->modelInstances[$model])) {
// Model exists, let's build the method name
$method = 'get' . ucfirst($property);
// Does the method exist?
if (method_exists($this->modelInstances[$model], $method)) {
// The method exists, let's call it and return what we get
$result = $this->modelInstances[$model]->{$method}();
return $result;
} else {
$result = $this->modelInstances[$model]->{$property}();
if (is_null($result)) {
return $default;
}
return $result;
}
} else {
if (@isset($this->{$property})) {
return $this->{$property};
} else {
return $default;
}
}
}