public function save($comment, $attributes, $userId = null)
{
$publication = $this->publicationService->getPublication();
// If the user was unknown (public comment) and public comments were moderated
// or the user was known (subscriber comment) and subscriber comments were moderated
// set the comment status to 'pending'. Otherwise, set the status to 'approved'.
if (!is_null($userId) && $publication->getCommentsSubscribersModerated() || is_null($userId) && $publication->getCommentsPublicModerated()) {
$attributes['status'] = "pending";
} else {
$attributes['status'] = "approved";
}
$comment = $this->em->getRepository('Newscoop\\Entity\\Comment')->save($comment, $attributes);
// save persisted comment object
$this->em->flush($comment);
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheService->clearNamespace('comment');
return $comment;
}