dm = $dm; } /** * Set the DocumentManager instance this purger instance should use. */ public function setDocumentManager(DocumentManager $dm) { $this->dm = $dm; } /** * Retrieve the DocumentManager instance this purger instance is using. * * @return DocumentManager */ public function getObjectManager() { return $this->dm; } /** @inheritDoc */ public function purge() { $metadatas = $this->dm->getMetadataFactory()->getAllMetadata(); foreach ($metadatas as $metadata) { if ($metadata->isMappedSuperclass) { continue; } $this->dm->getDocumentCollection($metadata->name)->drop(); } $this->dm->getSchemaManager()->ensureIndexes(); } }