/**
  * Delete data
  *
  * @param object $model Object that you want to delete
  * @param bool $flush Remove in database or not
  * @return bool
  */
 public function delete($model, $flush = true)
 {
     //Remove object
     $this->entityManager->remove($model);
     //Remove in database
     if ($flush) {
         $this->entityManager->flush();
     }
     return true;
 }
示例#2
0
 public function testRemove()
 {
     $movie = new Entity\Movie();
     $movie->setTitle('Terminator');
     $eventManager = $this->getEventManagerWithListenerExpectations(array('prePersist' => 1, 'postPersist' => 1, 'preRemove' => 1, 'postRemove' => 1));
     $this->em->setEventManager($eventManager);
     $this->em->persist($movie);
     $this->em->flush();
     $this->em->remove($movie);
     $this->em->flush();
 }