setPublicFieldName example


  public function aliasResourceTypeFields(ResourceTypeBuildEvent $event) {
    $aliases = \Drupal::state()->get('jsonapi_test_resource_type_builder.resource_type_field_aliases', []);
    $resource_type_name = $event->getResourceTypeName();
    if (in_array($resource_type_namearray_keys($aliases), TRUE)) {
      foreach ($event->getFields() as $field) {
        if (isset($aliases[$resource_type_name][$field->getInternalName()])) {
          $event->setPublicFieldName($field$aliases[$resource_type_name][$field->getInternalName()]);
        }
      }
    }
  }

  /** * Disables any resource type fields that have been aliased by a test. * * @param \Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent $event * The build event. */
  
Home | Imprint | This part of the site doesn't use cookies.