-
Notifications
You must be signed in to change notification settings - Fork 0
/
elastic_search.php
executable file
·47 lines (39 loc) · 1.11 KB
/
elastic_search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace PMVC\PlugIn\elastic_search;
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__.'\elastic_search';
\PMVC\l(__DIR__.'/src/db.php');
\PMVC\l(__DIR__.'/src/server.php');
class elastic_search extends \PMVC\PlugIn
{
private $servers = array();
public function init()
{
}
public function getDb($key)
{
$path = \PMVC\lastSlash($this['dbs']).$key.'.php';
if(\PMVC\realpath($path)){
\PMVC\l($path);
$class = __NAMESPACE__.'\\'.$key;
if(class_exists($class)){
return new $class;
} else {
trigger_error($class .' not exists.');
}
} else {
trigger_error($path .' not exists.');
}
}
public function getDefaultServer()
{
if (empty($this->servers[''])) {
$server = new server();
$server->scheme = $this['SCHEME'];
$server->host = $this['HOST'];
$server->port = $this['PORT'];
$server->auth = $this['AUTH'];
$this->servers[''] = $server;
}
return $this->servers[''];
}
}