// The registry still works on theme globals, so set them here.
\Drupal::
theme()->
setActiveTheme(\Drupal::
service('theme.initialization'
)->
getActiveThemeByName('test_theme'
));
// Reset the theme registry, so that the new theme is used.
$this->container->
set('theme.registry', NULL
);
// Load array of Twig templates.
// reset() is necessary to invalidate caches tagged with 'theme_registry'.
$registry =
$this->container->
get('theme.registry'
);
$registry->
reset();
$templates =
$registry->
getRuntime();
// Get the template filename and the cache filename for
// theme_test.template_test.html.twig.
$info =
$templates->
get('theme_test_template_test'
);
$template_filename =
$info['path'
] . '/' .
$info['template'
] .
$extension;
$environment =
$this->container->
get('twig'
);
$cache =
$environment->
getCache();
$class =
$environment->
getTemplateClass($template_filename);
$cache_filename =
$cache->
generateKey($template_filename,
$class);