You are here

protected function EntryPoint::getFieldMappings in Entity Share 8.3

Get all field mappings so clients are aware of the server configuration.

[ 'entity_type_id' => [ 'bundle' => [ 'internal name' => 'public name', ], ], ];

Return value

array An array as explained in the text above.

1 call to EntryPoint::getFieldMappings()
EntryPoint::index in modules/entity_share_server/src/Controller/EntryPoint.php
Controller to list all the resources.

File

modules/entity_share_server/src/Controller/EntryPoint.php, line 141

Class

EntryPoint
Controller to generate list of channels URLs.

Namespace

Drupal\entity_share_server\Controller

Code

protected function getFieldMappings() {
  $mapping = [];
  $definitions = $this
    ->entityTypeManager()
    ->getDefinitions();
  $resource_types = $this->resourceTypeRepository
    ->all();
  foreach ($resource_types as $resource_type) {
    $entity_type_id = $resource_type
      ->getEntityTypeId();

    // Do not expose config entities and user, as we do not manage them.
    if ($entity_type_id == 'user' || $definitions[$entity_type_id]
      ->getGroup() != 'content') {
      continue;
    }
    $bundle = $resource_type
      ->getBundle();
    $resource_type_fields = $resource_type
      ->getFields();
    foreach ($resource_type_fields as $resource_type_field) {
      $mapping[$entity_type_id][$bundle][$resource_type_field
        ->getInternalName()] = $resource_type_field
        ->getPublicName();
    }
  }
  return $mapping;
}