public function getModelSource($model)
{
$modelName = is_string($model) ? $model : get_class($model);
if (!isset($this->_sources[$modelName])) {
if ($this->_recallGetModelSource) {
return Text::underscore(Text::contains($modelName, '\\') ? substr($modelName, strrpos($modelName, '\\') + 1) : $modelName);
}
$modelInstance = is_string($model) ? new $model() : $model;
/** @noinspection NotOptimalIfConditionsInspection */
if (!isset($this->_sources[$modelName])) {
$this->_recallGetModelSource = true;
$this->_sources[$modelName] = $modelInstance->getSource();
$this->_recallGetModelSource = false;
}
}
return $this->_sources[$modelName];
}