コード例 #1
0
 private function generateViolationListFromDataProvider($subject, $id, array $violations)
 {
     $violationList = new TestedClass($subject, $id);
     foreach ($violations as $violation) {
         $violationList->add($violation);
     }
     return $violationList;
 }
コード例 #2
0
 /**
  * @{inheritdoc}
  */
 public function validate($object, Violation\ViolationList $violationList)
 {
     $errors = $this->validator->validate($object);
     foreach ($errors as $error) {
         $constraint = call_user_func_array(array($this->model, 'createFromConstraintViolation'), array($error));
         $violationList->add($constraint);
     }
     return $violationList;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function getViolationListNotFixed($model)
 {
     $modelClass = $this->getClassForModel($model);
     $modelId = $model->getId();
     $list = new ViolationList($modelClass, $modelId);
     $violations = $this->getObjectManager()->getRepository($this->violationClass)->createQueryBuilder('v')->where('v.fixed = :fixed')->andWhere('v.subjectModel = :subjectModel')->andWhere('v.subjectId = :subjectId')->setParameter('fixed', false)->setParameter('subjectModel', $modelClass)->setParameter('subjectId', $modelId)->orderBy('v.createdAt', 'DESC')->getQuery()->getResult();
     foreach ($violations as $violation) {
         $list->add($violation);
     }
     return $list;
 }
コード例 #4
0
 /**
  * Return the violation only present in th current instance, or in the
  * $violationList parameters.
  *
  * @param ViolationList $violationList
  * @return ViolationList
  * @throws \LogicException
  */
 public function diff(ViolationList $violationList)
 {
     if (!$this->hasSameSubject($violationList)) {
         throw new \LogicException('You can\'t diff ValidationList who haven\'t the same subject.');
     }
     $diffViolationList = new ViolationList($this->subjectModel, $this->subjectId);
     foreach ($this as $violation) {
         if (false === $violationList->contains($violation)) {
             $diffViolationList->add($violation);
         }
     }
     foreach ($violationList as $violation) {
         if (false === $this->contains($violation)) {
             $diffViolationList->add($violation);
         }
     }
     return $diffViolationList;
 }