function rate_entity_view in Rate 8
Same name and namespace in other branches
- 8.2 rate.module \rate_entity_view()
Implements hook_entity_view().
File
- ./
rate.module, line 42 - Hook implementation code for the Rate module.
Code
function rate_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if (($widget_config = $display
->getComponent('rate_vote_widget')) && $view_mode == 'full') {
$vote_widget_service = \Drupal::service('rate.entity.vote_widget');
$vote_widget = $vote_widget_service
->buildRateVotingWidget($entity
->id(), $entity
->getEntityTypeId(), $entity
->bundle());
if (isset($vote_widget['rate_vote_widget'])) {
$vote_widget['rate_vote_widget']['#weight'] = isset($widget_config['weight']) ? $widget_config['weight'] : 2;
}
$build = array_merge($build, $vote_widget);
}
}