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

Breadcrumb

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

function AnyBase::pack

The type_url will be created according to the given message’s type and the value is encoded data from the given message..

Parameters

Message $msg A proto message.:

File

vendor/google/protobuf/src/Google/Protobuf/Internal/AnyBase.php, line 55

Class

AnyBase
Base class for Google\Protobuf\Any, this contains hand-written convenience methods like pack() and unpack().

Namespace

Google\Protobuf\Internal

Code

public function pack($msg) {
    if (!$msg instanceof Message) {
        trigger_error("Given parameter is not a message instance.", E_USER_ERROR);
        return;
    }
    // Set value using serialized message.
    $this->value = $msg->serializeToString();
    // Set type url.
    $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
    $desc = $pool->getDescriptorByClassName(get_class($msg));
    $fully_qualified_name = $desc->getFullName();
    $this->type_url = GPBUtil::TYPE_URL_PREFIX . $fully_qualified_name;
}

API Navigation

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