Esempio n. 1
0
 /**
  * Creates an Comment object based on a DB row.
  *
  * @param array $row The DB row containing Comment data.
  * @return \MicroCMS\Domain\Comment
  */
 protected function buildDomainObject($row)
 {
     $comment = new Comment();
     $comment->setId($row['com_id']);
     $comment->setContent($row['com_content']);
     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('user_id', $row)) {
         // Find and set the associated author
         $userId = $row['user_id'];
         $user = $this->userDAO->find($userId);
         $comment->setAuthor($user);
     }
     return $comment;
 }