protected function TocTypeForm::getTemplates in TOC API 8
Get TOC templates from the theme registry for the default theme as an associative array of options.
Return value
array TOC templates as an associative array of options.
1 call to TocTypeForm::getTemplates()
- TocTypeForm::buildForm in src/
TocTypeForm.php - Form constructor.
File
- src/
TocTypeForm.php, line 397
Class
- TocTypeForm
- Base form for TOC type add and edit forms.
Namespace
Drupal\toc_apiCode
protected function getTemplates() {
$default_theme = $this->themeInitialization
->getActiveThemeByName($this
->config('system.theme')
->get('default'));
$active_theme = $this->themeManager
->getActiveTheme();
// Switch to the default theme.
$this->themeManager
->setActiveTheme($default_theme);
$templates = [];
$registry = $this->themeRegistry
->get();
foreach ($registry as $template_name => $template_settings) {
// Find toc_* templates with the toc_type variable set.
if (strpos($template_name, 'toc_') === 0 && !empty($template_settings['variables']['toc_type'])) {
$toc_name = $template_settings['variables']['toc_type'];
$templates[$toc_name] = $toc_name;
}
}
// Switch back to the active theme.
$this->themeManager
->setActiveTheme($active_theme);
return $templates;
}