You are here

protected function LinkClassFormatter::buildUrl in Open Social 8.9

Same name and namespace in other branches
  1. 8.8 modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
  2. 10.3.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
  3. 10.0.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
  4. 10.1.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
  5. 10.2.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()

Builds the \Drupal\Core\Url object for a link field item.

Parameters

\Drupal\link\LinkItemInterface $item: The link field item being rendered.

Return value

\Drupal\Core\Url A Url object.

Overrides LinkFormatter::buildUrl

File

modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php, line 65

Class

LinkClassFormatter
Plugin implementation of the 'link' formatter.

Namespace

Drupal\social_core\Plugin\Field\FieldFormatter

Code

protected function buildUrl(LinkItemInterface $item) {
  $url = parent::buildUrl($item);
  $settings = $this
    ->getSettings();
  if (!empty($settings['class'])) {
    $options = $url
      ->getOptions();
    $options['attributes']['class'] = $settings['class'];
    $url
      ->setOptions($options);
  }
  return $url;
}