Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (62 sloc) 1.84 KB
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2013-2016 Zend Technologies USA Inc. (http://www.zend.com)
*/
namespace ZF\ContentValidation\Validator\Db;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Stdlib\ArrayUtils;
use Zend\Validator\Db\RecordExists;
class RecordExistsFactory implements FactoryInterface
{
/**
* Required for v2 compatibility.
*
* @var null|array
*/
private $options;
/**
* Create and return a RecordExists validator instance.
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
* @return RecordExists
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
if (isset($options['adapter'])) {
return new RecordExists(ArrayUtils::merge(
$options,
['adapter' => $container->get($options['adapter'])]
));
}
return new RecordExists($options);
}
/**
* Create and return a RecordExists validator instance (v2).
*
* Provided for backwards compatibility; proxies to __invoke().
*
* @param ServiceLocatorInterface $validators
* @return RecordExists
*/
public function createService(ServiceLocatorInterface $validators)
{
$container = $validators->getServiceLocator() ?: $validators;
return $this($container, RecordExists::class, $this->options);
}
/**
* Set options property
*
* Implemented for backwards compatibility.
*
* @param array $options
*/
public function setCreationOptions(array $options)
{
$this->options = $options;
}
}
You can’t perform that action at this time.