function better_field_descriptions_theme in Better Field Descriptions 8
Same name and namespace in other branches
- 7 better_field_descriptions.module \better_field_descriptions_theme()
Implements hook_theme().
File
- ./
better_field_descriptions.module, line 27 - Module file for the Better field descriptions module.
Code
function better_field_descriptions_theme($existing, $type, $theme, $path) {
$bfd = \Drupal::config('better_field_descriptions.settings')
->get('better_field_descriptions');
// Find the theme template or use default if not configured.
if (isset($bfd['template']) == FALSE || empty($bfd['template'])) {
$template_file = 'better-field-descriptions-fieldset';
}
else {
$template_file = $bfd['template'];
}
// Find the theme template URI .
if ($template_file == 'better-field-descriptions-fieldset') {
$template_uri = drupal_get_path('module', 'better_field_descriptions') . '/templates';
}
else {
$template_uri = $bfd['template_uri'];
$template_uri = str_replace('/' . $template_file . '.html.twig', '', $template_uri);
}
return [
'better_field_descriptions' => [
'variables' => [
'label' => NULL,
'description' => NULL,
'required' => NULL,
],
'template' => $template_file,
'path' => $template_uri,
],
];
}