private function getDbHandler(ModelInterface $model)
{
if (!$this->db instanceof AdapterInterface) {
if ($model->getDi()->has('db')) {
$db = $model->getDi()->getShared('db');
if (!$db instanceof AdapterInterface) {
throw new Exception('The "db" service which was obtained from DI is invalid adapter.');
}
$this->db = $db;
} else {
throw new Exception('Undefined database handler.');
}
}
return $this->db;
}