Skip to content
Snippets Groups Projects
Commit 7d670f5c authored by Jan Tattermusch's avatar Jan Tattermusch Committed by GitHub
Browse files

Merge pull request #6634 from stanley-cheung/php-add-channel-to-stub-constructor

PHP: add optional channel argument to BaseStub constructor
parents 55ca239b e05d3196
No related branches found
No related tags found
No related merge requests found
......@@ -52,8 +52,9 @@ class BaseStub
* - 'update_metadata': (optional) a callback function which takes in a
* metadata array, and returns an updated metadata array
* - 'grpc.primary_user_agent': (optional) a user-agent string
* @param $channel Channel An already created Channel object
*/
public function __construct($hostname, $opts)
public function __construct($hostname, $opts, $channel = null)
{
$this->hostname = $hostname;
$this->update_metadata = null;
......@@ -77,7 +78,15 @@ class BaseStub
'required. Please see one of the '.
'ChannelCredentials::create methods');
}
$this->channel = new Channel($hostname, $opts);
if ($channel) {
if (!is_a($channel, 'Channel')) {
throw new \Exception("The channel argument is not a".
"Channel object");
}
$this->channel = $channel;
} else {
$this->channel = new Channel($hostname, $opts);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment