You are here

protected function JsonApiGenerator::getBundleTag in OpenAPI for JSON:API 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php \Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator\JsonApiGenerator::getBundleTag()

Get the tag to use for a bundle.

Parameters

string $entity_type_id: The entity type.

string $bundle_name: The entity type.

Return value

string The bundle tag.

3 calls to JsonApiGenerator::getBundleTag()
JsonApiGenerator::getPaths in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
JsonApiGenerator::getRouteMethodSummary in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Gets description of a method on a route.
JsonApiGenerator::getTags in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php

File

src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php, line 869

Class

JsonApiGenerator
Defines an OpenApi Schema Generator for the JsonApi module.

Namespace

Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator

Code

protected function getBundleTag($entity_type_id, $bundle_name = NULL) {
  static $tags = [];
  if (!isset($tags[$entity_type_id][$bundle_name])) {
    $entity_type = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    $tag = $entity_type
      ->getLabel();
    if ($bundle_name && ($bundle_type_id = $entity_type
      ->getBundleEntityType())) {
      $bundle_entity = $this->entityTypeManager
        ->getStorage($bundle_type_id)
        ->load($bundle_name);
      $tag .= ' - ' . $bundle_entity
        ->label();
    }
    $tags[$entity_type_id][$bundle_name] = $tag;
  }
  return $tags[$entity_type_id][$bundle_name];
}