private function loadFormatsFromFile($path, array &$formats)
    {
        $folder = dirname($path);
        $file = basename($path);

        $locator = new FileLocator($folder);

        $xmlLoader10 = new XmlFormatLoader10($locator);
        $xmlLoader11 = new XmlFormatLoader11($locator);
        $xmlLoader10->setGlobalOptions($this->globalOptions);
        $xmlLoader11->setGlobalOptions($this->globalOptions);

        $resolver = new LoaderResolver([$xmlLoader10, $xmlLoader11]);
        $loader = new DelegatingLoader($resolver);

        $fileFormats = $loader->load($file);
        foreach ($fileFormats as $format) {
            if (array_key_exists($format['key'], $formats) && $formats[$format['key']] !== $format) {
                throw new InvalidArgumentException(
                    sprintf('Media format with key "%s" already exists!', $format['key'])
                );
            }

            $formats[$format['key']] = $format;
        }
    }