/**
* {@inheritdoc}
*/
public function clear()
{
if ($this->initialized && $this->isEmpty()) {
return;
}
if ($this->isOrphanRemovalEnabled()) {
$this->initialize();
foreach ($this->coll as $element) {
$this->uow->scheduleOrphanRemoval($element);
}
}
$this->mongoData = array();
$this->coll->clear();
// Nothing to do for inverse-side collections
if (!$this->mapping['isOwningSide']) {
return;
}
// Nothing to do if the collection was initialized but contained no data
if ($this->initialized && empty($this->snapshot)) {
return;
}
$this->changed();
$this->uow->scheduleCollectionDeletion($this);
$this->takeSnapshot();
}