private function checkRestoreVersion(EnvironmentInterface $environment, ModelId $modelId)
    {
        $inputProvider = $environment->getInputProvider();

        $dataProviderDefinition = $environment->getDataDefinition()->getDataProviderDefinition();
        $dataProvider           = $environment->getDataProvider($modelId->getDataProviderName());

        if (!((null !== ($modelVersion = $inputProvider->getValue('version')))
            && ('tl_version' === $inputProvider->getValue('FORM_SUBMIT'))
            && $dataProviderDefinition->getInformation($modelId->getDataProviderName())->isVersioningEnabled())
        ) {
            return;
        }

        if (null === ($model = $dataProvider->getVersion($modelId->getId(), $modelVersion))) {
            $message = \sprintf(
                'Could not load version %s of record ID %s from %s',
                $modelVersion,
                $modelId->getId(),
                $modelId->getDataProviderName()
            );

            $environment->getEventDispatcher()->dispatch(
                ContaoEvents::SYSTEM_LOG,
                new LogEvent($message, TL_ERROR, 'DC_General - checkRestoreVersion()')
            );

            throw new DcGeneralRuntimeException($message);
        }

        $dataProvider->save($model);
        $dataProvider->setVersionActive($modelId->getId(), $modelVersion);
        $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_RELOAD, new ReloadEvent());
    }