public function saveObjects($data, $manager)
 {
     // type object
     $object = new UserDecisionRequisiteHistorical();
     // fields object
     $object->setUser($this->getReference($data['ref-user']));
     $object->setHistorical($this->getReference($data['ref-requisitehistorical']));
     $object->setState($this->getReference($data['ref-state']));
     $object->setDescription($data['description']);
     $this->setReference($data['ref-self'], $object);
     // persist
     $manager->persist($object);
     $manager->flush();
 }
 public function setUserDecisionStateForRequisiteHistorical($user, $requisiteHistorical, $decisionState)
 {
     //Check for another user's decision
     $query = $this->createQueryBuilder('q')->select('q')->where('q.user = :user')->setParameter('user', $user)->andWhere('q.historical = :historical')->setParameter('historical', $requisiteHistorical)->getQuery();
     $result = $query->getOneOrNullResult();
     // yes decision for this historical/user
     if ($result !== null) {
         echo "Distinto de null";
         $result->setState($decisionState);
         $this->getEntityManager()->persist($result);
         $this->getEntityManager()->flush();
     } else {
         // no decision for this historical/user
         echo "no decision;create";
         $userDecision = new UserDecisionRequisiteHistorical();
         $userDecision->setState($decisionState);
         $userDecision->setHistorical($requisiteHistorical);
         $userDecision->setUser($user);
         $userDecision->setDescription('');
         $this->getEntityManager()->persist($userDecision);
         $this->getEntityManager()->flush();
     }
 }