public function loadById($model, $id)
{
try {
$model->data = $this->app->pathfinder->locate($model->_table[$this->short_name], $id, 'array');
} catch (Exception_PathFinder $e) {
throw $this->exception('Requested file not found', 'NotFound')->by($e);
}
if (!$model->data) {
return;
}
$model->id = $id;
// If location field is not defined, get rid unnecessary reference
if (!$model->hasElement('location')) {
unset($model->data['location']);
}
// only load contents if field is defined
if ($model->hasElement('data') && $model->data['path']) {
$model->data['data'] = file_get_contents($model->data['path']);
}
}