Skip to content

Commit

Permalink
fix comments ussage after change for thread property
Browse files Browse the repository at this point in the history
  • Loading branch information
ahilles107 committed Apr 12, 2015
1 parent b5616a0 commit f71d3a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 40 deletions.
36 changes: 2 additions & 34 deletions newscoop/library/Newscoop/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,6 @@ class Comment implements DocumentInterface
*/
protected $thread;

/**
* @ORM\ManyToOne(targetEntity="Newscoop\Entity\Article")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="fk_thread_id", referencedColumnName="Number"),
* @ORM\JoinColumn(name="fk_language_id", referencedColumnName="IdLanguage")
* })
*/
protected $article;

/**
* @ORM\ManyToOne(targetEntity="Newscoop\Entity\Language")
* @ORM\JoinColumn(name="fk_language_id", referencedColumnName="Id")
Expand Down Expand Up @@ -212,29 +203,6 @@ public function getId()
return $this->id;
}

/**
* Set article
*
* @param Newscoop\Entity\Article $article
* @return void
*/
public function setArticle(Article $article)
{
$this->article = $article;

return $this;
}

/**
* Get article
*
* @return Newscoop\Entity\Article
*/
public function getArticle()
{
return $this->article;
}

/**
* Set timecreated
*
Expand Down Expand Up @@ -507,7 +475,7 @@ public function getForum()
*
* @return Newscoop\Entity\Comment
*/
public function setThread(Article $thread)
public function setThread($thread)
{
$this->thread = $thread;

Expand All @@ -517,7 +485,7 @@ public function setThread(Article $thread)
/**
* Get thread
*
* @return Newscoop\Entity\Articles
* @return int
*/
public function getThread()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function save(Comment $entity, $values)
->andWhere('c.thread = :thread')
->andWhere('c.language = :language')
->setParameter('parent', $parent)
->setParameter('thread', $parent->getThread()->getId())
->setParameter('thread', $parent->getThread())
->setParameter('language', $parent->getLanguage()->getId());

$threadOrder = $threadOrder->getQuery()->getSingleScalarResult();
Expand All @@ -325,7 +325,7 @@ public function save(Comment $entity, $values)
->andWhere('c.thread = :thread')
->andWhere('c.language = :language')
->setParameter('language', $parent->getLanguage()->getId())
->setParameter('thread', $parent->getThread()->getId())
->setParameter('thread', $parent->getThread())
->setParameter('thread_order', $threadOrder);
$qb->getQuery()->execute();
// set the thread level the thread level of the parent plus one the current level
Expand Down Expand Up @@ -356,7 +356,7 @@ public function save(Comment $entity, $values)
$entity
->setLanguage($language)
->setForum($thread->getPublication())
->setThread($thread);
->setThread($thread->getNumber());
}

$entity->setThreadOrder($threadOrder)->setThreadLevel($threadLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function update(GenericEvent $event)
{
$comment = $this->commentService->find($event['id']);
$article = $this->em->getRepository('Newscoop\Entity\Article')
->getArticle($comment->getThread()->getNumber(), $comment->getLanguage()->getId())
->getArticle($comment->getThread(), $comment->getLanguage()->getId())
->getSingleResult();

try {
Expand All @@ -60,7 +60,7 @@ public function update(GenericEvent $event)
$user = null;
}

$authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread()->getNumber(), $comment->getLanguage()->getId());
$authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread(), $comment->getLanguage()->getId());
$this->emailService->sendCommentNotification($comment, $article, $authors, $user);
}
}
3 changes: 2 additions & 1 deletion newscoop/template_engine/classes/CampURIShortNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ private function _getLanguage($code, MetaPublication $publication)
/**
* Get issue
*
* @param string $name
* @param string $name
*
* @return MetaIssue
*/
private function _getIssue($name, MetaLanguage $language, MetaPublication $publication)
Expand Down

0 comments on commit f71d3a2

Please sign in to comment.