protected function getObjectManager(ClassMetadata $metadata): ?ObjectManager
    {
        foreach ($this->managerRegistryCollection as $managerRegistry) {
            if ($objectManager = $managerRegistry->getManagerForClass($metadata->getName())) {
                return $objectManager;
            }
        }

        return null;
    }