You are here

public function LinkedFieldManager::getDestination in Linked Field 8

Get the destination for a set field or custom text.

Parameters

string $type: The type of the destination, either 'field' or 'custom'.

string $value: The value of the destination.

array $context: An array of context information.

Return value

string Getting the destination.

Overrides LinkedFieldManagerInterface::getDestination

File

src/LinkedFieldManager.php, line 141

Class

LinkedFieldManager
Provides helper methods for client related functionalities.

Namespace

Drupal\linked_field

Code

public function getDestination($type, $value, array $context) {
  $uri = '';
  if ($type == 'field') {

    /** @var \Drupal\Core\Field\FieldItemListInterface $field_items */
    $field_items = $context['entity']
      ->get($value);
    if (!$field_items
      ->count()) {
      return FALSE;
    }
    $uri = $this
      ->getFieldValue($field_items);
  }
  elseif ($type == 'custom') {

    // If custom type is used we simply return the custom text so we
    // can replace tokens later on.
    $uri = $value;
  }
  return $uri;
}