You are here

public function ResourceType::__get in Drupal 8

File

core/modules/jsonapi/src/ResourceType/ResourceType.php, line 441

Class

ResourceType
Value object containing all metadata for a JSON:API resource type.

Namespace

Drupal\jsonapi\ResourceType

Code

public function __get($name) {
  $class_name = self::class;
  @trigger_error("Using the {${$name}} protected property of a {$class_name} is deprecated in Drupal 8.8.0 and will not be allowed in Drupal 9.0.0. Use {$class_name}::getFields() instead. See https://www.drupal.org/node/3084721.", E_USER_DEPRECATED);
  if ($name === 'disabledFields') {
    return array_map(function (ResourceTypeField $field) {
      return $field
        ->getInternalName();
    }, array_filter($this
      ->getFields(), function (ResourceTypeField $field) {
      return !$field
        ->isFieldEnabled();
    }));
  }
  if ($name === 'invertedFieldMapping') {
    return array_reduce($this
      ->getFields(), function ($inverted_field_mapping, ResourceTypeField $field) {
      $internal_field_name = $field
        ->getInternalName();
      $public_field_name = $field
        ->getPublicName();
      if ($field
        ->isFieldEnabled() && $internal_field_name !== $public_field_name) {
        $inverted_field_mapping[$public_field_name] = $internal_field_name;
      }
      return $inverted_field_mapping;
    }, []);
  }
}