public function getById($id = null)
{
try {
if ($id != null) {
$this->model->setId($id);
}
$data = $this->db->fetchRow("SELECT documents.*, documents_link.*, tree_locks.locked FROM documents\n LEFT JOIN documents_link ON documents.id = documents_link.id\n LEFT JOIN tree_locks ON documents.id = tree_locks.id AND tree_locks.type = 'document'\n WHERE documents.id = ?", $this->model->getId());
if ($data["id"] > 0) {
$this->assignVariablesToModel($data);
$this->model->getHref();
} else {
throw new \Exception("Link with the ID " . $this->model->getId() . " doesn't exists");
}
} catch (\Exception $e) {
throw $e;
}
}