Вход Регистрация
Файл: symfony-2.7/src/Symfony/Component/Validator/Validator/LegacyValidator.php
Строк: 173
<?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 SymfonyComponentValidatorValidator;

use 
SymfonyComponentValidatorConstraint;
use 
SymfonyComponentValidatorConstraintsGroupSequence;
use 
SymfonyComponentValidatorConstraintsValid;
use 
SymfonyComponentValidatorValidatorInterface as LegacyValidatorInterface;

/**
 * A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+.
 *
 * @since  2.5
 * @author Bernhard Schussek <bschussek@gmail.com>
 *
 * @see SymfonyComponentValidatorValidatorInterface
 * @see SymfonyComponentValidatorValidatorValidatorInterface
 *
 * @deprecated since version 2.5, to be removed in 3.0.
 */
class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface
{
    public function 
validate($value$groups null$traverse false$deep false)
    {
        
$numArgs func_num_args();

        
// Use new signature if constraints are given in the second argument
        
if (self::testConstraints($groups) && ($numArgs || === $numArgs && self::testGroups($traverse))) {
            
// Rename to avoid total confusion ;)
            
$constraints $groups;
            
$groups $traverse;

            return 
parent::validate($value$constraints$groups);
        }

        
trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the SymfonyComponentValidatorValidatorValidatorInterface::validate method instead.'E_USER_DEPRECATED);

        
$constraint = new Valid(array('traverse' => $traverse'deep' => $deep));

        return 
parent::validate($value$constraint$groups);
    }

    public function 
validateValue($value$constraints$groups null)
    {
        
trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the SymfonyComponentValidatorValidatorValidatorInterface::validate method instead.'E_USER_DEPRECATED);

        return 
parent::validate($value$constraints$groups);
    }

    public function 
getMetadataFactory()
    {
        
trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the SymfonyComponentValidatorValidatorValidatorInterface::getMetadataFor or SymfonyComponentValidatorValidatorValidatorInterface::hasMetadataFor method instead.'E_USER_DEPRECATED);

        return 
$this->metadataFactory;
    }

    private static function 
testConstraints($constraints)
    {
        return 
null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint);
    }

    private static function 
testGroups($groups)
    {
        return 
null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence));
    }
}
Онлайн: 1
Реклама