aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php
diff options
context:
space:
mode:
authorGravatar Zhouyihai Ding <ddyihai@google.com>2018-05-17 09:26:07 -0700
committerGravatar GitHub <noreply@github.com>2018-05-17 09:26:07 -0700
commit10470bb4a0881e9f7d82cf88c448bfc6417d0ed0 (patch)
treefc771ea254112d1583874ebb26d47138cb688200 /src/php
parente8f3aa5cc50b6f4e91dfe032f64ea2a321f11a53 (diff)
parent6d96a9a6126fb94a3e0975ddfdf0791fb81e6060 (diff)
Merge pull request #15417 from chingor13/php-default-channel
PHP: Surface a static method to fetch the default Channel
Diffstat (limited to 'src/php')
-rw-r--r--src/php/lib/Grpc/BaseStub.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index 0966193107..b9c50b1da6 100644
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -69,6 +69,18 @@ class BaseStub
return;
}
+ $this->channel = static::getDefaultChannel($hostname, $opts);
+ }
+
+ /**
+ * Creates and returns the default Channel
+ *
+ * @param array $opts Channel constructor options
+ *
+ * @return Channel The channel
+ */
+ public static function getDefaultChannel($hostname, array $opts)
+ {
$package_config = json_decode(
file_get_contents(dirname(__FILE__).'/../../composer.json'),
true
@@ -85,7 +97,7 @@ class BaseStub
'required. Please see one of the '.
'ChannelCredentials::create methods');
}
- $this->channel = new Channel($hostname, $opts);
+ return new Channel($hostname, $opts);
}
/**