* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\RuntimeException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Fabien Potencier * @author Bernhard Schussek */ class ExpressionValidator extends ConstraintValidator { private $expressionLanguage; public function __construct($propertyAccessor = null, ExpressionLanguage $expressionLanguage = null) { $this->expressionLanguage = $expressionLanguage; } /** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof Expression) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Expression'); } $variables = array(); $variables['value'] = $value; $variables['this'] = $this->context->getObject(); if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING)) ->setCode(Expression::EXPRESSION_FAILED_ERROR) ->addViolation(); } } private function getExpressionLanguage() { if (null === $this->expressionLanguage) { if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); } $this->expressionLanguage = new ExpressionLanguage(); } return $this->expressionLanguage; } } __halt_compiler();----SIGNATURE:----TQd+4XeW5+j4zMXwSYYOxMUQWfnZ5zhy3C8neQE75yoXrCFTBh0z0yYF3E3jASr9ecYgwMcGtWK2Ap5spEZpNktn5VjHhWlEmZHlzkEyaDxc/8JJkXEWKxMzDW5lBhX7rMB9neA9xfTzgjiMivOJbRGsOSsxgZrbAW5Qmm3Hp09jG7CPXrvDuQJGqyFhWqvD2T7KLhoeVB8AMPTxTYkUNFLwr0J8grxRmoTMcNejDlEgiC3YeqO4vDXbDOe+iz2N5YFH38L5nKNCH23R3JK8u2vff5RDqE6xs0p/AXe/kBKsO+In0kFPuFm8F7rlVCUfA5c7pvOz1Mjl+WMJmvpgFqujFGbjNWY5wbTZ68iZBQJcwh7I/eaINBbYuddydyKJf7WoNTfhgyBVp5Gt2k+80nfBi4m61wBBZ9Oo6exdMpw84TLxjQ8eM6aBfzq/kttYUxrQ95L074RUox5L0BXX9R4v3EzAEKuzL7LgXnBcl/Op53vb3H1oVk7FEyh1P8uCqV/f+IGLxKZbilWeH57T5y2CIT+S2mHmm3VcJyvRQ+I/G00w+MQ3PqfCQsyU5f5Zfjlff+rnRQktN9WO66K4dWGpLfWVdx2vp23Mk0r0C6d5QObQLNdoBmG/VlegOtbddfcWOLUvwnfzMGQhg6Iyb1XF0YvnRg6YZJW5eToS2HY=----ATTACHMENT:----NjczODA1MTk3OTc0ODQ4MyA3MDc2MzU0MTY5MDI5Mjk5IDE2MjM0NTM5MTA0MDg5MDA=