-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathModule.php
44 lines (38 loc) · 1.21 KB
/
Module.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
<?php
namespace ZfGearmanManager;
use GearmanClient;
class Module
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getServiceConfig()
{
return array(
'factories' => array(
'GearmanClient' => function ($sm) {
$gmClient = new GearmanClient();
$config = $sm->get('Config');
if(isset($config['gearman_client'])){
$conf = $config['gearman_client'];
}
$host = isset($conf['host']) ? $conf['host'] : '127.0.0.1';
$port = isset($conf['port']) ? $conf['port'] : 4730;
// add default server (localhost)
$gmClient->addServer($host, $port);
return $gmClient;
},
),
'invokables' => array(
'ZfGearmanPeclManager' => 'ZfGearmanManager\ZfGearmanPeclManager',
),
);
}
}