Doctrine\ORM\EntityManager::clear PHP Method

clear() public method

Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.
public clear ( string $entityName = null )
$entityName string
    public function clear($entityName = null)
    {
        if ($entityName === null) {
            $this->unitOfWork->clear();
        } else {
            //TODO
            throw new ORMException("EntityManager#clear(\$entityName) not yet implemented.");
        }
    }

Usage Example

 /**
  * @param float $discount
  */
 public function apply($discount)
 {
     $this->entityManager->transactional(function () use($discount) {
         foreach ($this->items->findAll() as $item) {
             $item->applyDiscount($discount);
         }
     });
     $this->entityManager->clear();
 }
All Usage Examples Of Doctrine\ORM\EntityManager::clear