function fblikebutton_node_view in Facebook Like Button 8
Same name and namespace in other branches
- 7.2 fblikebutton.module \fblikebutton_node_view()
- 7 fblikebutton.module \fblikebutton_node_view()
Implements hook_ENTITY_TYPE_view().
File
- ./
fblikebutton.module, line 27
Code
function fblikebutton_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
$user = $account = \Drupal::currentUser();
$config = \Drupal::config('fblikebutton.settings');
$types = $config
->get('node_types');
$full_node_display = $config
->get('full_node_display');
$teaser_display = $config
->get('teaser_display');
$full = $view_mode == 'full' ? TRUE : FALSE;
$show = $types[$node
->getType()] && $user
->hasPermission('access fblikebutton');
$likebutton_weight = $config
->get('weight');
if ($show) {
// Content area
if ($view_mode == 'teaser' && $teaser_display == 1 || $view_mode == 'full' && $full_node_display == 0) {
$url = fblikebutton_get_node_url($node
->id());
$build['fblikebutton_field'] = array(
'#theme' => 'fblikebutton',
'#weight' => $likebutton_weight,
'#url' => $url,
);
}
}
}