protected function FlippingBookLinkFormatter::buildUrl in Flipping Book 8
1 call to FlippingBookLinkFormatter::buildUrl()
- FlippingBookLinkFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ FlippingBookLinkFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ FlippingBookLinkFormatter.php, line 98
Class
- FlippingBookLinkFormatter
- Plugin implementation of the 'flipping_book_link_formatter' formatter.
Namespace
Drupal\flipping_book\Plugin\Field\FieldFormatterCode
protected function buildUrl(FileItem $item) {
$flipping_book = $item
->getRoot()
->getValue();
/** @var Url $url */
$url = \Drupal::service('flipping_book')
->buildFlippingBookUrl($flipping_book);
$settings = $this
->getSettings();
$options = $url
->getOptions();
// Add optional 'rel' attribute to link options.
if (!empty($settings['rel'])) {
$options['attributes']['rel'] = $settings['rel'];
}
// Add optional 'target' attribute to link options.
if (!empty($settings['target'])) {
$options['attributes']['target'] = $settings['target'];
}
$url
->setOptions($options);
return $url;
}