public function __construct(DocumentManagerInterface $dm)
{
$this->dm = $dm;
$this->session = $dm->getPhpcrSession();
$this->eventListenersInvoker = new ListenersInvoker($dm);
$this->eventManager = $dm->getEventManager();
$config = $dm->getConfiguration();
$this->documentClassMapper = $config->getDocumentClassMapper();
$this->validateDocumentName = $config->getValidateDoctrineMetadata();
$this->writeMetadata = $config->getWriteDoctrineMetadata();
$this->uuidGenerator = $config->getUuidGenerator();
if ($this->session instanceof JackalopeSession) {
$this->useFetchDepth = 'jackalope.fetch_depth';
}
}