/
JobsPublisherFactory.php
54 lines (47 loc) · 1.58 KB
/
JobsPublisherFactory.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
48
49
50
51
52
53
54
<?php
/**
* YAWIK
*
* @filesource
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de)
* @license MIT
* @author weitz@cross-solution.de
*/
namespace Jobs\Factory\Service;
use Core\Factory\Service\RestClientFactory;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Class JobsPublisherFactory
* @package Jobs\Factory\Service
*/
class JobsPublisherFactory extends RestClientFactory
{
protected $config;
/**
* @var ServiceLocatorInterface $serviceLocator
*/
protected $serviceLocator;
protected function getUri() {
$config = $this->getConfig();
if (!array_key_exists('uri', $config)) {
throw new \RuntimeException('uri for Rest-Server YAWIK is missing', 500);
}
return $config['uri'];
}
protected function getConfig() {
if (!isset($this->config)) {
$config = $this->serviceLocator->get('Config');
if (!array_key_exists('multiposting', $config)) {
throw new \RuntimeException('configuration for multiposting is missing', 500);
}
if (!array_key_exists('target', $config['multiposting'])) {
throw new \RuntimeException('target for multiposting is missing', 500);
}
if (!array_key_exists('restServer', $config['multiposting']['target'])) {
throw new \RuntimeException('configuration restServer for multiposting.target is missing', 500);
}
$this->config = $config['multiposting']['target']['restServer'];
}
return $this->config;
}
}