public function getConstraints()
 {
     if (is_null($this->constraints)) {
         $fields = array();
         foreach ($this->getFieldsRecursively() as $fc_field) {
             $fields[] = $fc_field->getId();
         }
         $this->constraints = FcFieldConstraintQuery::create()->filterByFieldId($fields)->filterByIsActive(true)->find();
     }
     return $this->constraints;
 }
 /**
  * Sets constraint's active state
  *
  * @param Request $request
  * @param $item_id
  * @param $active
  * @return JsonResponse
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  */
 public function setConstraintStateAction(Request $request, $item_id, $active)
 {
     if (!$request->isXmlHttpRequest()) {
         throw $this->createAccessDeniedException();
     }
     $fc_constraint = FcFieldConstraintQuery::create()->findPk($item_id);
     if (!$fc_constraint instanceof FcFieldConstraint) {
         throw $this->createNotFoundException();
     }
     $fc_constraint->setIsActive($active);
     $fc_constraint->save();
     return new JsonResponse(array('success' => true));
 }