protected function parseTheme(DirectoryInterface $themeDir, array $generalConfig)
    {
        $themeConfig = $this->parseConfigYaml('theme.yml', $themeDir);

        /** @deprecated Deprecated since 3.0, to be removed in 4.0. (config.yml was the old filename) */
        if (empty($themeConfig)) {
            $themeConfig = $this->parseConfigYaml('config.yml', $themeDir);
        }

        if ((isset($themeConfig['templatefields'])) && (is_array($themeConfig['templatefields']))) {
            $templateContentTypes = [];

            foreach ($themeConfig['templatefields'] as $template => $templateFields) {
                $fieldsContenttype = [
                    'fields'        => $templateFields,
                    'singular_name' => 'Template Fields ' . $template,
                ];

                try {
                    $templateContentTypes[$template] = $this->parseContentType(
                        $template,
                        $fieldsContenttype,
                        $generalConfig
                    );
                } catch (InvalidArgumentException $e) {
                    $this->exceptions[] = $e->getMessage();
                }
            }

            $themeConfig['templatefields'] = $templateContentTypes;
        }

        return $themeConfig;
    }