You are here

protected function JsonApiGenerator::isToManyRelationship in OpenAPI for JSON:API 3.x

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

Checks if the relationship is to-many.

Parameters

string $route_name: The route name.

\Drupal\jsonapi\ResourceType\ResourceType $resource_type: The resource type.

Return value

bool Indicates if the relationship is multiple cardinality.

2 calls to JsonApiGenerator::isToManyRelationship()
JsonApiGenerator::getEntityResponsesJsonApi in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
JsonApiGenerator::getMethodParameters in src/Plugin/openapi/OpenApiGenerator/JsonApiGenerator.php
Get the parameters array for a method on a route.

File

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

Class

JsonApiGenerator
Defines an OpenApi Schema Generator for the JsonApi module.

Namespace

Drupal\openapi_jsonapi\Plugin\openapi\OpenApiGenerator

Code

protected function isToManyRelationship($route_name, ResourceType $resource_type) {
  $public_field_name = explode('.', $route_name)[2];
  $internal_field_name = $resource_type
    ->getInternalName($public_field_name);
  $field_definitions = $this->fieldManager
    ->getFieldDefinitions($resource_type
    ->getEntityTypeId(), $resource_type
    ->getBundle());
  return $field_definitions[$internal_field_name]
    ->getFieldStorageDefinition()
    ->getCardinality() !== 1;
}