コード例 #1
0
 /**
  * Don't allow creating variant group type if one already exists
  *
  * @param GroupTypeInterface $groupType
  * @param Constraint         $constraint
  */
 public function validate($groupType, Constraint $constraint)
 {
     if ($groupType->isVariant()) {
         $variantGroupType = $this->groupTypeRepository->getVariantGroupType();
         if (null !== $variantGroupType && $variantGroupType->getId() !== $groupType->getId()) {
             $this->context->buildViolation($constraint->message)->addViolation();
         }
     }
 }