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 MehrAlsNix\FeatureToggle\Mvc\Controller\Plugin\FeatureToggle; |
22
|
|
|
use Zend\ServiceManager\Exception\ServiceNotFoundException; |
23
|
|
|
use Zend\ServiceManager\FactoryInterface; |
24
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
25
|
|
|
|
26
|
|
|
class FeatureToggleControllerPluginFactory implements FactoryInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Create service |
30
|
|
|
* |
31
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
32
|
|
|
* |
33
|
|
|
* @return FeatureToggle |
34
|
|
|
* |
35
|
|
|
* @throws ServiceNotFoundException |
36
|
|
|
*/ |
37
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
38
|
|
|
{ |
39
|
|
|
$serviceLocator = $serviceLocator->getServiceLocator(); |
40
|
|
|
$toggleManager = $serviceLocator->get('ToggleManagerFactory'); |
41
|
|
|
$toggleContext = $serviceLocator->get('ToggleContextFactory'); |
42
|
|
|
|
43
|
|
|
$plugin = new FeatureToggle(); |
44
|
|
|
$plugin->setToggleManager($toggleManager); |
45
|
|
|
$plugin->setContext($toggleContext); |
46
|
|
|
|
47
|
|
|
return $plugin; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|