protected function parseMetadataMapping(MappingDriverChain $metadataDriverChain)
    {
        foreach ((array) $this->getOption('metadata_mapping') as $metadataMapping) {
            if (!is_array($metadataMapping)) {
                $metadataMapping = ['driver' => $metadataMapping];
            }

            if (!array_key_exists('namespace', $metadataMapping) && $metadataDriverChain->getDefaultDriver() !== null) {
                throw new \RuntimeException(
                    'Only one default metadata mapping driver allowed, a namespace must be defined'
                );
            }

            $mappingDriver = $this->getMappingDriver($metadataMapping);

            if (array_key_exists('namespace', $metadataMapping)) {
                $metadataDriverChain->addDriver($mappingDriver, $metadataMapping['namespace']);
            } else {
                $metadataDriverChain->setDefaultDriver($mappingDriver);
            }
        }
    }