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