|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @author [email protected] |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Jobs\Factory\Options; |
|
12
|
|
|
|
|
13
|
|
|
use Interop\Container\ContainerInterface; |
|
14
|
|
|
use Jobs\Options\ProviderOptions; |
|
15
|
|
|
use Zend\ServiceManager\FactoryInterface; |
|
16
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
17
|
|
|
|
|
18
|
|
|
class ProviderOptionsFactory implements FactoryInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Create an object |
|
22
|
|
|
* |
|
23
|
|
|
* @param ContainerInterface $container |
|
24
|
|
|
* @param string $requestedName |
|
25
|
|
|
* @param null|array $options |
|
26
|
|
|
* |
|
27
|
|
|
* @return object |
|
28
|
|
|
* @throws ServiceNotFoundException if unable to resolve the service. |
|
29
|
|
|
* @throws ServiceNotCreatedException if an exception is raised when |
|
30
|
|
|
* creating a service. |
|
31
|
|
|
* @throws ContainerException if any other error occurs |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
34
|
|
|
{ |
|
35
|
|
|
$config = $container->get('Config'); |
|
36
|
|
|
$multiposting = array_key_exists('multiposting', $config) ? $config['multiposting'] : array(); |
|
37
|
|
|
|
|
38
|
|
|
$providerOptions = new ProviderOptions(); |
|
39
|
|
|
|
|
40
|
|
|
if (array_key_exists('channels', $multiposting)) { |
|
41
|
|
|
foreach ($multiposting['channels'] as $channelName => $channel) { |
|
42
|
|
|
$channelOptions = $container->get('Jobs/Options/Channel'); |
|
43
|
|
|
if (empty($channelOptions->key)) { |
|
44
|
|
|
$channelOptions->key = $channelName; |
|
45
|
|
|
} |
|
46
|
|
|
$channelOptions->setFromArray($channel); |
|
47
|
|
|
$providerOptions->addChannel($channelOptions); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
return $providerOptions; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
|
54
|
|
|
{ |
|
55
|
|
|
return $this($serviceLocator, ProviderOptions::class); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|