public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); }
/** * Delete a commenter * * @param Newscoop\Entity\Comment\Commenter $p_commenter * @param array $p_values * @return void */ public function delete(Commenter $p_commenter, $p_values) { $em = $this->getEntityManager(); $q = $em->createQueryBuilder(); /** @todo have inverse cascade delete or somethig for this */ $q->select("cc")->from('Newscoop\\Entity\\Comment\\Commenter', 'cc')->where('cc.id = :id')->setParameter('id', $p_commenter->getId()); if (!empty($p_values['name'])) { $q->orWhere('cc.name = :name')->setParameter('name', $p_commenter->getName()); } if (!empty($p_values['ip'])) { $q->orWhere('cc.ip = :ip')->setParameter('ip', $p_commenter->getIp()); } if (!empty($p_values['email'])) { $q->orWhere('cc.email = :email')->setParameter('email', $p_commenter->getEmail()); } $commenters = $q->getQuery()->getResult(); foreach ($commenters as $commenter) { $qq = $em->createQueryBuilder(); $qq->delete()->from('Newscoop\\Entity\\Comment', 'c')->where('c.commenter = :commenter')->setParameter('commenter', $commenter->getId()); $qq->getQuery()->execute(); $em->remove($commenter); } }