You are here

public function FreelinkingManager::buildLink in Freelinking 8.3

Same name and namespace in other branches
  1. 4.0.x src/FreelinkingManager.php \Drupal\freelinking\FreelinkingManager::buildLink()

Build link structure for a plugin with target parameters.

Parameters

\Drupal\freelinking\Plugin\FreelinkingPluginInterface $plugin: The freelinking plugin.

array $target: The target array. @see ::parseTarget().

Return value

mixed Either an array or a string.

Overrides FreelinkingManagerInterface::buildLink

1 call to FreelinkingManager::buildLink()
FreelinkingManager::createFreelinkElement in src/FreelinkingManager.php
Create the render array for the respective Freelinking plugin.

File

src/FreelinkingManager.php, line 87

Class

FreelinkingManager
Freelinking plugin manager.

Namespace

Drupal\freelinking

Code

public function buildLink(FreelinkingPluginInterface $plugin, array $target) {
  $link = $plugin
    ->buildLink($target);

  // Allow modules a chance to alter the freelink link array for complex
  // plugins that return an array.
  if (is_array($link)) {
    $data = [
      'target' => $target,
      'plugin_name' => $plugin
        ->getPluginId(),
      'plugin' => $plugin,
    ];
    $this->moduleHandler
      ->alter('freelinking_freelink', $link, $data);
  }
  return $link;
}