You are here

function shariff_node_view in Shariff Social Media Buttons 8

Implements hook_ENTITY_TYPE_view().

File

./shariff.module, line 244
Integrating Shariff library, providing settings form and block.

Code

function shariff_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  if ($display
    ->getComponent('shariff_field')) {

    // Get settings.
    $settings = _shariff_get_settings();

    // Load shariff library.
    $variant = isset($settings['css']) ? $settings['css'] : 'complete';
    $build['shariff_field'] = [
      '#theme' => 'block_shariff',
      '#blocksettings' => NULL,
      '#attached' => [
        'library' => [
          'shariff/shariff-' . $variant,
        ],
      ],
    ];
  }
}