Doctrine\ODM\MongoDB\PersistentCollection::clear PHP Method

clear() public method

public clear ( )
    public function clear()
    {
        if ($this->initialized && $this->isEmpty()) {
            return;
        }
        if ($this->mapping !== null && isset($this->mapping['embedded'])) {
            foreach ($this->coll as $element) {
                $this->dm->getUnitOfWork()->scheduleOrphanRemoval($element);
            }
        }
        $this->coll->clear();
        $this->changed();
        $this->dm->getUnitOfWork()->scheduleCollectionDeletion($this);
        $this->takeSnapshot();
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function clear()
 {
     $this->collection->clear();
 }