本文整理汇总了PHP中Client::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getConnection方法的具体用法?PHP Client::getConnection怎么用?PHP Client::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::getConnection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConnection
public function getConnection($method, $path, $data = null, array $headers = array())
{
$start = microtime(true);
$response = $this->client->getConnection($method, $path, $data, $headers);
$duration = microtime(true) - $start;
$this->requests[] = array('duration' => $duration, 'method' => $method, 'path' => rawurldecode($path), 'request' => $data, 'request_size' => strlen($data), 'response_status' => $response->status, 'response' => $response->body, 'response_headers' => $response->headers);
$this->totalDuration += $duration;
return $response;
}
示例2: execute
/**
* Execute query
*
* @access public
* @param string $baseDn
* @param string $filter
* @param array $attributes
* @return Query
*/
public function execute($baseDn, $filter, array $attributes)
{
$sr = ldap_search($this->client->getConnection(), $baseDn, $filter, $attributes);
if ($sr === false) {
return $this;
}
$entries = ldap_get_entries($this->client->getConnection(), $sr);
if ($entries === false || count($entries) === 0 || $entries['count'] == 0) {
return $this;
}
$this->entries = $entries;
return $this;
}
示例3: testConnectFailureWithTLS
public function testConnectFailureWithTLS()
{
self::$functions->expects($this->once())->method('ldap_connect')->with($this->equalTo('my_ldap_server'), $this->equalTo(389))->will($this->returnValue('my_ldap_resource'));
self::$functions->expects($this->once())->method('ldap_start_tls')->with($this->equalTo('my_ldap_resource'))->will($this->returnValue(false));
$this->setExpectedException('\\Kanboard\\Core\\Ldap\\ClientException');
$ldap = new Client();
$this->assertNotEquals('my_ldap_resource', $ldap->getConnection('my_ldap_server', 389, true));
}
示例4: checkCapabilities
/**
* Checks if the passed client instance satisfies the required conditions
* needed to initialize a monitor context.
*
* @param Client Client instance used by the context.
*/
private function checkCapabilities(Client $client)
{
if (Helpers::isCluster($client->getConnection())) {
throw new ClientException('Cannot initialize a monitor context over a cluster of connections');
}
if ($client->getProfile()->supportsCommand('monitor') === false) {
throw new ClientException('The current profile does not support the MONITOR command');
}
}
示例5: checkCapabilities
/**
* Checks if the passed client instance satisfies the required conditions
* needed to initialize a Publish / Subscribe context.
*
* @param Client Client instance used by the context.
*/
private function checkCapabilities(Client $client)
{
if (Helpers::isCluster($client->getConnection())) {
throw new ClientException('Cannot initialize a PUB/SUB context over a cluster of connections');
}
$commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe');
if ($client->getProfile()->supportsCommands($commands) === false) {
throw new ClientException('The current profile does not support PUB/SUB related commands');
}
}
示例6: execute
/**
* Execute query
*
* @access public
* @param string $baseDn
* @param string $filter
* @param array $attributes
* @return Query
*/
public function execute($baseDn, $filter, array $attributes)
{
if (DEBUG && $this->client->hasLogger()) {
$this->client->getLogger()->debug('BaseDN=' . $baseDn);
$this->client->getLogger()->debug('Filter=' . $filter);
$this->client->getLogger()->debug('Attributes=' . implode(', ', $attributes));
}
$sr = ldap_search($this->client->getConnection(), $baseDn, $filter, $attributes);
if ($sr === false) {
return $this;
}
$entries = ldap_get_entries($this->client->getConnection(), $sr);
if ($entries === false || count($entries) === 0 || $entries['count'] == 0) {
return $this;
}
$this->entries = $entries;
if (DEBUG && $this->client->hasLogger()) {
$this->client->getLogger()->debug('NbEntries=' . $entries['count']);
}
return $this;
}
示例7: removeClient
public function removeClient(Client $client)
{
if ($this->disconnect_callback) {
call_user_func_array($this->disconnect_callback, [$client]);
}
$buf = $client->getBuffer();
$conn = $client->getConnection();
event_buffer_disable($buf, EV_READ | EV_WRITE);
event_buffer_free($buf);
fclose($conn);
}