entity_extra_field.theme in Entity Extra Field 2.0.x
File
templates/entity_extra_field.theme
View source
<?php
declare (strict_types=1);
use Drupal\entity_extra_field\Entity\EntityExtraFieldInterface;
function template_preprocess_entity_extra_field(array &$variables) : void {
$element = $variables['element'];
$extra_field = $element['#field'];
$variables['label'] = $element['label'];
$variables['content'] = $element['content'];
$variables['attributes']['class'][] = 'extra-field';
if ($extra_field instanceof EntityExtraFieldInterface) {
$field_class_name = entity_extra_field_class_string([
$extra_field
->name(),
]);
$variables['attributes']['class'][] = 'extra-field--' . $field_class_name;
$variables['attributes']['class'][] = 'extra-field--type-' . $extra_field
->getFieldTypePluginId();
}
$variables['title_attributes']['class'][] = 'extra-field--label';
$variables['content_attributes']['class'][] = 'extra-field--content';
}
function entity_extra_field_class_string(array $values, string $delimiter = '-') : string {
return implode($delimiter, array_map('\\Drupal\\Component\\Utility\\Html::getClass', $values));
}