1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Adlogix package. |
4
|
|
|
* |
5
|
|
|
* (c) Allan Segebarth <[email protected]> |
6
|
|
|
* (c) Jean-Jacques Courtens <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Adlogix\Zf2Rollout\Service\Factory; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
use Adlogix\Zf2Rollout\Service\Controller\RolloutController; |
16
|
|
|
use Interop\Container\ContainerInterface; |
17
|
|
|
use Opensoft\Rollout\Rollout; |
18
|
|
|
use Opensoft\Rollout\RolloutUserInterface; |
19
|
|
|
use Zend\Mvc\Controller\ControllerManager; |
20
|
|
|
use Zend\ServiceManager\FactoryInterface; |
21
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Toni Van de Voorde <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
final class RolloutControllerFactory implements FactoryInterface |
27
|
|
|
{ |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
33
|
|
|
{ |
34
|
|
|
return $this($serviceLocator, null); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
41
|
|
|
{ |
42
|
|
|
if ($container instanceof ControllerManager) { |
43
|
|
|
$container = $container->getServiceLocator(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** @var Rollout $rollout */ |
47
|
|
|
$rollout = $container->get('zf2_rollout'); |
48
|
|
|
|
49
|
|
|
/** @var RolloutUserInterface $rolloutUser */ |
50
|
|
|
$rolloutUser = $container->get('zf2_rollout_user'); |
51
|
|
|
|
52
|
|
|
return new RolloutController($rollout, $rolloutUser); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|