function entity_test_entity_prepare_view in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_prepare_view()
Implements hook_entity_prepare_view().
File
- core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module, line 608 - Test module for the entity API providing several entity types for testing.
Code
function entity_test_entity_prepare_view($entity_type, array $entities, array $displays) {
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity_type == 'entity_test') {
foreach ($entities as $entity) {
if ($entity
->hasField('field_test_text') && $displays[$entity
->bundle()]
->getComponent('field_test_text')) {
foreach ($entity
->get('field_test_text') as $item) {
$item->_attributes += array(
'data-field-item-attr' => 'foobar',
);
}
}
}
}
}