Doctrine\Search\UnitOfWork::remove PHP Method

remove() public method

Deletes an entity as part of the current unit of work.
public remove ( object $entity )
$entity object The entity to remove.
    public function remove($entity)
    {
        if ($this->evm->hasListeners(Events::preRemove)) {
            $this->evm->dispatchEvent(Events::preRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }
        $oid = spl_object_hash($entity);
        $this->scheduledForDelete[$oid] = $entity;
        if ($this->evm->hasListeners(Events::postRemove)) {
            $this->evm->dispatchEvent(Events::postRemove, new Event\LifecycleEventArgs($entity, $this->sm));
        }
    }

Usage Example

示例#1
0
 /**
  * Remove the object from the index
  *
  * @param array|object $objects
  *
  * @throws UnexpectedTypeException
  */
 public function remove($objects)
 {
     if (!is_array($objects) && !$objects instanceof \Traversable) {
         $objects = array($objects);
     }
     foreach ($objects as $object) {
         if (!is_object($object)) {
             throw new UnexpectedTypeException($object, 'object');
         }
         $this->unitOfWork->remove($object);
     }
 }