/** * Creates an Comment object based on a DB row. * * @param array $row The DB row containing Comment data. * @return \NanarStore\Domain\Comment */ protected function buildDomainObject($row) { $comment = new Comment(); $comment->setId($row['com_id']); $comment->setContent($row['com_content']); $comment->setGrade($row['com_grade']); if (array_key_exists('art_id', $row)) { // Find and set the associated article $articleId = $row['art_id']; $article = $this->articleDAO->find($articleId); $comment->setArticle($article); } if (array_key_exists('usr_id', $row)) { // Find and set the associated author $userId = $row['usr_id']; $user = $this->userDAO->find($userId); $comment->setAuthor($user); } return $comment; }