remove() public method

Deletes an entity as part of the current unit of work.
public remove ( object $entity )
$entity object The entity to remove.
 /**
  * Removes an entity instance.
  *
  * A removed entity will be removed from the database at or before transaction commit
  * or as a result of the flush operation.
  *
  * @param object $entity The entity instance to remove.
  */
 public function remove($entity)
 {
     if (!is_object($entity)) {
         throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity);
     }
     $this->errorIfClosed();
     $this->unitOfWork->remove($entity);
 }
Example #2
0
 /**
  * Removes an entity instance.
  *
  * A removed entity will be removed from the database at or before transaction commit
  * or as a result of the flush operation.
  *
  * @param object $entity The entity instance to remove.
  */
 public function remove($entity)
 {
     if (!is_object($entity)) {
         throw new \InvalidArgumentException(gettype($entity));
     }
     $this->errorIfClosed();
     $this->unitOfWork->remove($entity);
 }
Example #3
0
 /**
  * TODO: set deletedAt field through reflection and loading softdeletable config
  *
  * @param LifecycleEventArgs $eventArgs
  */
 public function postSoftDelete(LifecycleEventArgs $eventArgs)
 {
     if (!$this->active) {
         return;
     }
     $entity = $eventArgs->getEntity();
     $this->em = $eventArgs->getEntityManager();
     $this->uow = $this->em->getUnitOfWork();
     // this will ensure our handling in onFlush scheduled deletes will execute
     $this->uow->remove($entity);
 }