From 6f325805c0bc956f927b0e2dbfb4dd8133b4ed69 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 5 Jun 2017 00:10:18 -0700 Subject: Add new file option php_namespace. (#3162) * Add new file option php_namespace. Use this option to change the namespace of php generated classes. Default is empty. When this option is empty, the package name will be used for determining the namespace. * Uncomment commented tests * Revert gdb test change * Update csharp descriptor. * Add test for empty php_namespace. --- php/src/Google/Protobuf/descriptor.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'php/src/Google/Protobuf/descriptor.php') diff --git a/php/src/Google/Protobuf/descriptor.php b/php/src/Google/Protobuf/descriptor.php index 35e4929b..b7a3a550 100644 --- a/php/src/Google/Protobuf/descriptor.php +++ b/php/src/Google/Protobuf/descriptor.php @@ -282,6 +282,19 @@ function getFullClassName( $class_name_without_package = getClassNameWithoutPackage($message_name_without_package, $file_proto); + + $option = $file_proto->getOptions(); + if (!is_null($option) && $option->hasPhpNamespace()) { + $namespace = $option->getPhpNamespace(); + if ($namespace !== "") { + $classname = $namespace . "\\" . $class_name_without_package; + return; + } else { + $classname = $class_name_without_package; + return; + } + } + if ($package === "") { $classname = $class_name_without_package; } else { -- cgit v1.2.3