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\Exception\ServiceNotFoundException; |
26
|
|
|
use Zend\ServiceManager\Factory\FactoryInterface; |
27
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
28
|
|
|
|
29
|
|
|
class UserContextFactory implements FactoryInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Create service |
33
|
|
|
* |
34
|
|
|
* @param ContainerInterface $container |
35
|
|
|
* @param string $requestedName |
36
|
|
|
* @param array|null $options |
37
|
|
|
* |
38
|
|
|
* @return Context |
39
|
|
|
* |
40
|
|
|
* @throws \Psr\Container\ContainerExceptionInterface |
41
|
|
|
*/ |
42
|
1 |
|
public function __invoke(ContainerInterface $container, $requestedName = '', array $options = null) |
43
|
|
|
{ |
44
|
|
|
/** @var AuthenticationServiceInterface $storage */ |
45
|
1 |
|
$storage = $container->get('FeatureToggle\Storage'); |
46
|
|
|
|
47
|
1 |
|
$userContext = new UserContext($storage); |
48
|
|
|
|
49
|
1 |
|
return $userContext->createContext(); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|