Problem/Motivation
TextExtractor::extractPlainText() previously rendered each field's formatter under whatever theme happened to be active at call time. Since extraction is commonly triggered from an admin route (e.g. a node's Audio tab), fields ended up rendered under the admin theme rather than the site's front-end theme — producing TTS output based on admin-theme markup/formatting instead of what visitors actually see.
This adds a new rendering_theme setting (ai_audio_generator.settings) that lets the site builder pin extraction to a specific theme. TextExtractor now switches to that theme (falling back to the site default theme when unset) via ThemeManagerInterface/ThemeInitializationInterface before rendering fields, and always restores the original active theme afterward (try/finally), including on a MissingThemeDependencyException (e.g. a broken base-theme dependency), which is caught and logged as a warning rather than blocking audio generation.
Steps to reproduce
1. Set the site's default theme and admin theme to different themes.
2. Trigger TTS extraction from an admin-only route (e.g. the node Audio tab) while the admin theme is active.
3. Observe fields are rendered/formatted per the admin theme rather than the front-end theme.
Proposed resolution
Introduce ai_audio_generator.settings:rendering_theme and switch the active theme for the duration of field rendering in extractPlainText(), restoring it afterward.
Issue fork ai_audio_generator-3613805
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
nnevill