58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Symfony\Component\Validator;
|
|
|
|
class ConstraintViolation
|
|
{
|
|
protected $messageTemplate;
|
|
protected $messageParameters;
|
|
protected $root;
|
|
protected $propertyPath;
|
|
protected $invalidValue;
|
|
|
|
public function __construct($messageTemplate, array $messageParameters, $root, $propertyPath, $invalidValue)
|
|
{
|
|
$this->messageTemplate = $messageTemplate;
|
|
$this->messageParameters = $messageParameters;
|
|
$this->root = $root;
|
|
$this->propertyPath = $propertyPath;
|
|
$this->invalidValue = $invalidValue;
|
|
}
|
|
|
|
public function getMessageTemplate()
|
|
{
|
|
return $this->messageTemplate;
|
|
}
|
|
|
|
public function getMessageParameters()
|
|
{
|
|
return $this->messageParameters;
|
|
}
|
|
|
|
public function getMessage()
|
|
{
|
|
$sources = array();
|
|
$targets = array();
|
|
foreach ($this->messageParameters as $key => $value) {
|
|
$sources[] = '{{ '.$key.' }}';
|
|
$targets[] = (string) $value;
|
|
}
|
|
|
|
return str_replace($sources, $targets, $this->messageTemplate);
|
|
}
|
|
|
|
public function getRoot()
|
|
{
|
|
return $this->root;
|
|
}
|
|
|
|
public function getPropertyPath()
|
|
{
|
|
return $this->propertyPath;
|
|
}
|
|
|
|
public function getInvalidValue()
|
|
{
|
|
return $this->invalidValue;
|
|
}
|
|
} |