In Drupal 8:
I have custom module code that declares its own theme can twig template. How do I make module variables available to my Drupal theme's page.html.twig?
I have tried various preprocess_page* functions; however, those functions don't see the variables the module is passing to it's own themed twig templates.
Can the module's controller inject something into the page variables?
Can a Drupal theme's preprocess functions access some variables flowing from a custom module to the module's twig templates?
The controller file:
class PromtController extends ControllerBase
{
public function program($id)
{
$program = PromtService::program((int)$id);
return [
'#theme' => 'promt_program',
'#program' => $program,
'#title' => $program['title']
];
}
}
The module code:
function promt_theme()
{
return [
'promt_program' => [
'template' => 'promt_program',
'variables' => [
'program' => null
]
]
];
}