function _bricks_nest_get_new_element in Bricks 2.x
Assemble a render element based on existing content and field item data.
1 call to _bricks_nest_get_new_element()
File
- ./
bricks.module, line 117
Code
function _bricks_nest_get_new_element($content, int $item_delta, BricksFieldItemInterface $field_item, $parent) : array {
$element = $content;
$entity = $field_item->entity;
$element['#label'] = $entity
->label();
$element['#bricks_parent_key'] = $parent;
$element['#attributes']['class'][] = 'brick';
$element['#attributes']['class'][] = 'brick--type--' . Html::cleanCssIdentifier($entity
->bundle());
$element['#attributes']['class'][] = 'brick--id--' . $entity
->id();
$element['layout_children'] = [];
if ($view_mode = $field_item
->getOption('view_mode')) {
$element['#view_mode'] = $view_mode;
}
if ($layout = $field_item
->getOption('layout')) {
$element['#layout'] = $layout;
}
if ($css_class = $field_item
->getOption('css_class')) {
$element['#attributes']['class'][] = $css_class;
}
return $element;
}