This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Validator/ValidatorContext.php

86 lines
2.1 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator;
use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
/**
2011-03-01 17:55:38 +00:00
* Default implementation of ValidatorContextInterface
*
2012-05-26 08:48:33 +01:00
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class ValidatorContext implements ValidatorContextInterface
{
/**
* The class metadata factory used in the new validator
* @var ClassMetadataFactoryInterface
*/
protected $classMetadataFactory = null;
/**
* The constraint validator factory used in the new validator
* @var ConstraintValidatorFactoryInterface
*/
protected $constraintValidatorFactory = null;
/**
2012-07-11 13:59:45 +01:00
* {@inheritDoc}
*/
public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory)
{
$this->classMetadataFactory = $classMetadataFactory;
return $this;
}
/**
2012-07-11 13:59:45 +01:00
* {@inheritDoc}
*/
public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory)
{
$this->constraintValidatorFactory = $constraintValidatorFactory;
return $this;
}
/**
2012-07-11 13:59:45 +01:00
* {@inheritDoc}
*/
public function getValidator()
{
return new Validator(
$this->classMetadataFactory,
$this->constraintValidatorFactory
);
}
/**
* Returns the class metadata factory used in the new validator
*
* @return ClassMetadataFactoryInterface The factory instance
*/
public function getClassMetadataFactory()
{
return $this->classMetadataFactory;
}
/**
* Returns the constraint validator factory used in the new validator
*
* @return ConstraintValidatorFactoryInterface The factory instance
*/
public function getConstraintValidatorFactory()
{
return $this->constraintValidatorFactory;
}
}