protected function storeViewDataLegacy()
    {
        $originalArguments = [];

        $variableProvider = $this->getVariableProvider();

        foreach (self::$reservedVariablesNames as $key) {
            if ($variableProvider->exists($key)) {
                $originalArguments[$key] = $variableProvider->get($key);
            }
        }

        $viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer();
        $currentView = $viewHelperVariableContainer->getView();

        return function (array $templateArguments) use ($originalArguments, $variableProvider, $viewHelperVariableContainer, $currentView) {
            $viewHelperVariableContainer->setView($currentView);

            /*
             * Cleaning up the variables in the provider: the original
             * values are restored to make the provider like it was before
             * the field rendering started.
             */
            foreach ($variableProvider->getAllIdentifiers() as $identifier) {
                if (array_key_exists($identifier, $templateArguments)) {
                    $variableProvider->remove($identifier);
                }
            }

            foreach ($originalArguments as $key => $value) {
                if ($variableProvider->exists($key)) {
                    $variableProvider->remove($key);
                }

                $variableProvider->add($key, $value);
            }
        };
    }