/**
* Returns a named Model object. Makes sure that the Model is a database-aware model, throwing an exception
* otherwise, when $name is null.
*
* @param string $name The Model name. If null we'll use the modelName
* variable or, if it's empty, the same name as
* the Controller
* @param array $config Configuration parameters to the Model. If skipped
* we will use $this->config
*
* @return DataModel The instance of the Model known to this Controller
*
* @throws NotADataModel When the model type doesn't match our expectations
*/
public function getModel($name = null, $config = array())
{
$model = parent::getModel($name, $config);
if (is_null($name) && !$model instanceof DataModel) {
throw new NotADataModel('Model ' . get_class($model) . ' is not a database-aware Model');
}
return $model;
}