You are here

public function SmartDocsFormatter::view in Apigee API Catalog 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/SmartDocsFormatter.php \Drupal\apigee_api_catalog\Plugin\Field\FieldFormatter\SmartDocsFormatter::view()

Overrides EntityReferenceFormatterBase::view

See also

::prepareView()

::getEntitiestoView()

File

src/Plugin/Field/FieldFormatter/SmartDocsFormatter.php, line 97

Class

SmartDocsFormatter
Plugin implementation of the SmartDocs OpenAPI spec formatter.

Namespace

Drupal\apigee_api_catalog\Plugin\Field\FieldFormatter

Code

public function view(FieldItemListInterface $items, $langcode = NULL) {
  $elements = parent::view($items, $langcode);

  // Add base tag for SmartDocs Angular application.
  $xuacompatible = [
    '#tag' => 'base',
    '#attributes' => [
      'href' => base_path(),
    ],
  ];
  $elements['#attached']['html_head'][] = [
    $xuacompatible,
    'base-href',
  ];
  return $elements;
}