protected function LinkClassFormatter::buildUrl in Open Social 8.9
Same name and namespace in other branches
- 8.8 modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
- 10.3.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
- 10.0.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
- 10.1.x modules/social_features/social_core/src/Plugin/Field/FieldFormatter/LinkClassFormatter.php \Drupal\social_core\Plugin\Field\FieldFormatter\LinkClassFormatter::buildUrl()
- 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\FieldFormatterCode
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;
}