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

Breadcrumb

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

function MapEntry::__construct

Overrides Message::__construct

File

vendor/google/protobuf/src/Google/Protobuf/Internal/MapEntry.php, line 20

Class

MapEntry

Namespace

Google\Protobuf\Internal

Code

public function __construct($desc) {
    parent::__construct($desc);
    // For MapEntry, getValue should always return a valid value. Thus, we
    // need to create a default instance value if the value type is
    // message, in case no value is provided in data.
    $value_field = $desc->getFieldByNumber(2);
    if ($value_field->getType() == GPBType::MESSAGE) {
        $klass = $value_field->getMessageType()
            ->getClass();
        $value = new $klass();
        $this->setValue($value);
    }
}

API Navigation

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