Newscoop\Entity\Repository\CommentRepository::update PHP Method

update() public method

Method for update a comment
public update ( Comment $comment, array $values ) : Comment
$comment Newscoop\Entity\Comment
$values array
return Newscoop\Entity\Comment $enitity
    public function update(Comment $comment, $values)
    {
        // get the enitity manager
        $em = $this->getEntityManager();
        if (array_key_exists('subject', $values) && !is_null($values['subject'])) {
            $comment->setSubject($values['subject']);
        }
        if (array_key_exists('message', $values) && !is_null($values['message'])) {
            $comment->setMessage($values['message']);
        }
        if (array_key_exists('recommended', $values) && !is_null($values['recommended'])) {
            $comment->setRecommended($values['recommended']);
        }
        if (array_key_exists('status', $values) && !is_null($values['status'])) {
            $comment->setStatus($values['status']);
        }
        $comment->setTimeUpdated(new \DateTime());
        return $comment;
    }