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\Context; |
23
|
|
|
use MehrAlsNix\FeatureToggle\Context\UserContext; |
24
|
|
|
use Zend\Authentication\AuthenticationServiceInterface; |
25
|
|
|
use Zend\ServiceManager\FactoryInterface; |
26
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
27
|
|
|
|
28
|
|
|
class UserContextFactory implements FactoryInterface |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Create service |
32
|
|
|
* |
33
|
|
|
* @param ContainerInterface $container |
34
|
|
|
* @param string $requestedName |
35
|
|
|
* @param array|null $options |
36
|
|
|
* |
37
|
|
|
* @return Context |
38
|
|
|
* |
39
|
|
|
* @throws \Psr\Container\ContainerExceptionInterface |
40
|
|
|
*/ |
41
|
1 |
|
public function __invoke(ContainerInterface $container, $requestedName = '', array $options = null) |
42
|
|
|
{ |
43
|
|
|
/** @var AuthenticationServiceInterface $storage */ |
44
|
1 |
|
$storage = $container->get('FeatureToggle\Storage'); |
45
|
|
|
|
46
|
1 |
|
$userContext = new UserContext($storage); |
47
|
|
|
|
48
|
1 |
|
return $userContext->createContext(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Create service |
53
|
|
|
* |
54
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
55
|
|
|
* @return mixed |
56
|
|
|
*/ |
57
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
58
|
|
|
{ |
59
|
|
|
return $this($serviceLocator); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
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.