You are here

protected function OpenApiGeneratorBase::includeEntityTypeBundle in OpenAPI 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/openapi/OpenApiGeneratorBase.php \Drupal\openapi\Plugin\openapi\OpenApiGeneratorBase::includeEntityTypeBundle()

Determines if an entity type and/or bundle show be included.

Parameters

string $entity_type_id: The entity type id.

string|null $bundle_name: The bundle name.

Return value

bool True if the entity type or bundle should be included.

File

src/Plugin/openapi/OpenApiGeneratorBase.php, line 531

Class

OpenApiGeneratorBase
Defines base class for OpenApi Generator plugins.

Namespace

Drupal\openapi\Plugin\openapi

Code

protected function includeEntityTypeBundle($entity_type_id, $bundle_name = NULL) {

  // Entity types or a specific bundle be can excluded.
  if (isset($this->options['exclude'])) {
    if (array_intersect([
      $entity_type_id,
      $this
        ->getEntityDefinitionKey($entity_type_id, $bundle_name),
    ], $this->options['exclude'])) {
      return FALSE;
    }
  }
  if (isset($this->options['entity_mode'])) {
    $entity_type = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    if ($this->options['entity_mode'] == 'content_entities') {
      return $entity_type instanceof ContentEntityTypeInterface;
    }
    if ($this->options['entity_mode'] == 'config_entities') {
      return $entity_type instanceof ConfigEntityTypeInterface;
    }
  }
  if (isset($this->options['entity_type_id']) && $this->options['entity_type_id'] !== $entity_type_id) {
    return FALSE;
  }
  if (isset($bundle_name) && isset($this->options['bundle_name']) && $this->options['bundle_name'] !== $bundle_name) {
    return FALSE;
  }
  return TRUE;
}