本文整理匯總了PHP中Google\Protobuf\DescriptorProto::getExtensionList方法的典型用法代碼示例。如果您正苦於以下問題:PHP DescriptorProto::getExtensionList方法的具體用法?PHP DescriptorProto::getExtensionList怎麽用?PHP DescriptorProto::getExtensionList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Google\Protobuf\DescriptorProto
的用法示例。
在下文中一共展示了DescriptorProto::getExtensionList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUniqueFieldName
/**
* @param \google\protobuf\DescriptorProto $descriptor
* @param string $default
*
* @return string
*/
protected function getUniqueFieldName(DescriptorProto $descriptor, $default)
{
$extensions = $descriptor->getExtensionList() ?: [];
$fields = $descriptor->getFieldList() ?: [];
$name = $default;
$names = [];
$count = 0;
foreach ($fields as $field) {
$names[$field->getName()] = true;
}
foreach ($extensions as $field) {
$names[$field->getName()] = true;
}
while (isset($names[$name])) {
$name = $default . $count++;
}
return $name;
}
示例2: generateMessage
/**
* @param \google\protobuf\FileDescriptorProto $fileDescriptor
* @param \google\protobuf\DescriptorProto $messageDescriptor
* @param string $parent
*
* @return \Protobuf\Compiler\Entity
*/
protected function generateMessage(FileDescriptorProto $fileDescriptor, DescriptorProto $messageDescriptor, $parent = null)
{
$type = Entity::TYPE_MESSAGE;
$name = $messageDescriptor->getName();
$entity = new Entity($type, $name, $messageDescriptor, $fileDescriptor, $parent);
if ($messageDescriptor->hasExtensionList() && $this->containsProtobufExtension($messageDescriptor->getExtensionList())) {
$entity->setProtobufExtension(true);
}
return $entity;
}