|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK Stackoverflow API |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @license MIT |
|
7
|
|
|
* @copyright 2016 - 2017 Cross Solution <http://cross-solution.de> |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** */ |
|
11
|
|
|
namespace StackoverflowApi\Factory\Client; |
|
12
|
|
|
|
|
13
|
|
|
use Interop\Container\ContainerInterface; |
|
14
|
|
|
use StackoverflowApi\Client\DataTransformer; |
|
15
|
|
|
use Zend\ServiceManager\FactoryInterface; |
|
16
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Factory for \StackoverflowApi\Client\DataTransformer |
|
20
|
|
|
* |
|
21
|
|
|
* @author Mathias Gelhausen <[email protected]> |
|
22
|
|
|
* @since 0.1.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
class DataTransformerFactory implements FactoryInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Create a DataTransformer |
|
28
|
|
|
* |
|
29
|
|
|
* @param ContainerInterface $container |
|
30
|
|
|
* @param string $requestedName |
|
31
|
|
|
* @param array $options |
|
32
|
|
|
* |
|
33
|
|
|
* @return DataTransformer |
|
34
|
|
|
*/ |
|
35
|
1 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
36
|
|
|
{ |
|
37
|
1 |
|
$viewHelperManager = $container->get('ViewHelperManager'); |
|
38
|
1 |
|
$applyUrlHelper = $viewHelperManager->get('ApplyUrl'); |
|
39
|
1 |
|
$serverUrlHelper = $viewHelperManager->get('ServerUrl'); |
|
40
|
1 |
|
$orgImageManager = $container->get('Organizations\ImageFileCache\Manager'); |
|
41
|
1 |
|
$transformer = new DataTransformer(); |
|
42
|
|
|
|
|
43
|
|
|
$transformer |
|
44
|
1 |
|
->setApplyUrlHelper($applyUrlHelper) |
|
45
|
1 |
|
->setServerUrlHelper($serverUrlHelper) |
|
46
|
1 |
|
->setOrganizationImageManager($orgImageManager) |
|
47
|
|
|
; |
|
48
|
|
|
|
|
49
|
1 |
|
return $transformer; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Create service |
|
54
|
|
|
* |
|
55
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
|
56
|
|
|
* |
|
57
|
|
|
* @return DataTransformer |
|
58
|
|
|
*/ |
|
59
|
1 |
|
public function createService(ServiceLocatorInterface $serviceLocator) |
|
60
|
|
|
{ |
|
61
|
1 |
|
return $this($serviceLocator, DataTransformer::class); |
|
62
|
|
|
} |
|
63
|
|
|
} |