1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* zf2-featureflags. |
4
|
|
|
* |
5
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
6
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
7
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
8
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
10
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
11
|
|
|
* SOFTWARE. |
12
|
|
|
* |
13
|
|
|
* @copyright 2016 MehrAlsNix (http://www.mehralsnix.de) |
14
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
15
|
|
|
* |
16
|
|
|
* @link http://github.com/MehrAlsNix/zf2-featureflags |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace MehrAlsNix\FeatureToggle\Factory; |
20
|
|
|
|
21
|
|
|
use Interop\Container\ContainerInterface; |
22
|
|
|
use Qandidate\Toggle\ToggleCollection; |
23
|
|
|
use Qandidate\Toggle\ToggleManager; |
24
|
|
|
use Zend\ServiceManager\Exception\ServiceNotFoundException; |
25
|
|
|
use Zend\ServiceManager\FactoryInterface; |
26
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
27
|
|
|
|
28
|
|
|
class ToggleManagerFactory implements FactoryInterface |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Create service |
32
|
|
|
* |
33
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
|
|
|
|
34
|
|
|
* |
35
|
|
|
* @return ToggleManager |
36
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
37
|
|
|
*/ |
38
|
2 |
|
public function __invoke(ContainerInterface $container, $requestedName = '', array $options = null) |
39
|
|
|
{ |
40
|
2 |
|
$coll = $container->get( |
41
|
2 |
|
'ToggleFeature\InMemoryCollSerializer' |
42
|
2 |
|
)->deserialize( |
43
|
2 |
|
$container->get('config')['zf2_featureflags']['features'] |
44
|
|
|
); |
45
|
|
|
|
46
|
2 |
|
if (!$coll instanceof ToggleCollection) { |
47
|
1 |
|
throw new ServiceNotFoundException( |
48
|
1 |
|
'Service received is not of type ToggleCollection' |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
1 |
|
return new ToggleManager($coll); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Create service |
57
|
|
|
* |
58
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
59
|
|
|
* @return mixed |
60
|
|
|
*/ |
61
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
62
|
|
|
{ |
63
|
|
|
return $this($serviceLocator); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.