ResourceTypeAttribute example

    // necessary for certain Drupal-coupled clients, so we alias it by     // prefixing it with `drupal_internal__`.     // - exposing an entity's UUID as an attribute is useless (it's already part     // of the mandatory "id" attribute in JSON:API), so we disable it in most     // cases.     // - exposing its revision ID as an attribute will compete with any profile     // defined meta members used for resource object versioning.     // @see http://jsonapi.org/format/#document-resource-identifier-objects     $id_field_name = $entity_type->getKey('id');
    $uuid_field_name = $entity_type->getKey('uuid');
    if ($uuid_field_name && $uuid_field_name !== 'id') {
      $fields[$uuid_field_name] = new ResourceTypeAttribute($uuid_field_name, NULL, FALSE);
    }
    $fields[$id_field_name] = new ResourceTypeAttribute($id_field_name, "drupal_internal__$id_field_name");
    if ($entity_type->isRevisionable() && ($revision_id_field_name = $entity_type->getKey('revision'))) {
      $fields[$revision_id_field_name] = new ResourceTypeAttribute($revision_id_field_name, "drupal_internal__$revision_id_field_name");
    }
    if ($entity_type instanceof ConfigEntityTypeInterface) {
      // The '_core' key is reserved by Drupal core to handle complex edge cases       // correctly. Data in the '_core' key is irrelevant to clients reading       // configuration, and is not allowed to be set by clients writing       // configuration: it is for Drupal core only, and managed by Drupal core.       // @see https://www.drupal.org/node/2653358
Home | Imprint | This part of the site doesn't use cookies.