/** * * @access public * @param \CCDNForum\ForumBundle\Entity\Topic $topic * @param \Symfony\Component\Security\Core\User\UserInterface $user * @return \CCDNForum\ForumBundle\Manager\ManagerInterface */ public function softDelete(Topic $topic, UserInterface $user) { // Don't overwite previous users accountability. if (!$topic->getDeletedBy() && !$topic->getDeletedDate()) { $topic->setDeleted(true); $topic->setDeletedBy($user); $topic->setDeletedDate(new \DateTime()); // Close the topic as a precaution. $topic->setClosed(true); $topic->setClosedBy($user); $topic->setClosedDate(new \DateTime()); // update the record before doing record counts $this->persist($topic)->flush(); } return $this; }