for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Adlogix package.
*
* (c) Allan Segebarth <[email protected]>
* (c) Jean-Jacques Courtens <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Adlogix\Zf2Rollout\Service\Factory;
use Interop\Container\ContainerInterface;
use Opensoft\Rollout\Storage\StorageInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class RolloutStorageFactory implements FactoryInterface
{
private static $storage_service = 'storage_service';
/**
* {@inheritdoc}
public function createService(ServiceLocatorInterface $serviceLocator)
return $this($serviceLocator, null);
}
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
/** @var array $config */
$config = $container->get('zf2_rollout_config');
if (!isset($config[self::$storage_service]) || $config[self::$storage_service] === '') {
throw new \RuntimeException('No "' . self::$storage_service . '" defined in the rollout configuration!"');
$storage = $container->get($config[self::$storage_service]);
if (!$storage instanceof StorageInterface) {
throw new \RuntimeException(sprintf('The "' . self::$storage_service . '" should be an instance of StorageInterface but was %s',
get_class($storage)));
return $storage;