Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ProtobufSerializer.php

function ProtobufSerializer::traverseDescriptor

2 calls to ProtobufSerializer::traverseDescriptor()
ProtobufSerializer::postProcessJsonEnumValues in vendor/open-telemetry/exporter-otlp/ProtobufSerializer.php
Workaround until protobuf exposes `FormatEnumsAsIntegers` option.
ProtobufSerializer::traverseFieldDescriptor in vendor/open-telemetry/exporter-otlp/ProtobufSerializer.php

File

vendor/open-telemetry/exporter-otlp/ProtobufSerializer.php, line 118

Class

ProtobufSerializer
@internal @psalm-type SUPPORTED_CONTENT_TYPES = ContentTypes::PROTOBUF|ContentTypes::JSON|ContentTypes::NDJSON

Namespace

OpenTelemetry\Contrib\Otlp

Code

private static function traverseDescriptor(object $data, Descriptor $desc) : void {
    for ($i = 0, $n = $desc->getFieldCount(); $i < $n; $i++) {
        // @phan-suppress-next-line PhanParamTooManyInternal
        $field = $desc->getField($i);
        $name = lcfirst(strtr(ucwords((string) $field->getName(), '_'), [
            '_' => '',
        ]));
        if (!property_exists($data, $name)) {
            continue;
        }
        if ($field->getLabel() === GPBLabel::REPEATED) {
            foreach ($data->{$name} as $key => $value) {
                $data->{$name}[$key] = self::traverseFieldDescriptor($value, $field);
            }
        }
        else {
            $data->{$name} = self::traverseFieldDescriptor($data->{$name}, $field);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal