コード例 #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @api
  *
  * @param mixed $value The value that should be validated
  * @param \Symfony\Component\Validator\Constraint|\Spryker\Zed\Category\Communication\Constraint\CategoryNameExists $constraint The constraint for the validation
  *
  * @return void
  */
 public function validate($value, Constraint $constraint)
 {
     $idLocale = $constraint->getLocale()->getIdLocale();
     $idCategory = $constraint->getIdCategory();
     $categoryQueryContainer = $constraint->getQueryContainer();
     $categoryEntity = $categoryQueryContainer->queryCategory($value, $idLocale)->findOne();
     if ($categoryEntity !== null) {
         if ($idCategory === null || $idCategory !== $categoryEntity->getIdCategory()) {
             $this->addViolation($value, $constraint);
         }
     }
 }