You are here

protected function JsonApiGenerator::getBundleTag in OpenAPI 8

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
Returns the paths information.
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
Get tags for schema.

File

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

Class

JsonApiGenerator
Defines an OpenApi Schema Generator for the JsonApi module.

Namespace

Drupal\openapi\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];
}