public function serializeViolationToJson(JsonSerializationVisitor $visitor, ConstraintViolation $violation, array $type = null)
 {
     $data = array('property_path' => $violation->getPropertyPath(), 'message' => $violation->getMessage());
     if (null === $visitor->getRoot()) {
         $visitor->setRoot($data);
     }
     return $data;
 }
Exemplo n.º 2
0
 /** @HandlerCallback("json", direction = "serialization") */
 public function serializeToJson(JsonSerializationVisitor $visitor)
 {
     $visitor->setRoot(array($this->element => $this->value));
 }