You are here

function addtoany_create_entity_data in AddToAny Share Buttons 8

Generate data for AddToAny buttons for a node.

Parameters

object $node: The node object to create the buttons for.

object $config: If present this will be used as custom config data. Use NULL for default config data.

Return value

array The array with url, title, additional_html that will be send to Twig.

3 calls to addtoany_create_entity_data()
AddToAnyBlock::build in src/Plugin/Block/AddToAnyBlock.php
Builds and returns the renderable array for this block plugin.
addtoany_entity_view in ./addtoany.module
Implements hook_ENTITY_TYPE_view().
NodeAddToAnyShare::render in src/Plugin/views/field/NodeAddToAnyShare.php
inheritdoc}

File

./addtoany.module, line 198
Handle AddToAny integration.

Code

function addtoany_create_entity_data($node, $config = NULL) {
  $url = isset($node) ? $node
    ->toUrl('canonical', [
    'absolute' => TRUE,
  ])
    ->toString() : NULL;
  $title = isset($node) ? $node
    ->label() : NULL;
  return addtoany_create_data($url, $title, $config);
}