public function generate($document, ClassMetadata $cm, DocumentManagerInterface $dm, $parent = null)
    {
        $id = $cm->getFieldValue($document, $cm->identifier);
        if (!$id) {
            throw new IdException('ID could not be read from the document instance using the AssignedIdGenerator.');
        }

        return $id;
    }