public function load(ObjectManager $manager)
 {
     $question = $this->getReference('petition1');
     $answers = array(array('reference' => 'micropetition-answer1', 'user' => $this->getReference('user-mobile1'), 'option' => 1), array('reference' => 'micropetition-answer2', 'user' => $this->getReference('user-mobile2'), 'option' => 2), array('reference' => 'micropetition-answer3', 'user' => $this->getReference('user-mobile3'), 'option' => 1), array('reference' => 'petition-answer4', 'user' => $this->getReference('user-mobile5'), 'option' => 2));
     foreach ($answers as $data) {
         $answer = new Answer();
         $answer->setUser($data['user'])->setOptionId($data['option'])->setPetition($question);
         $this->addReference($data['reference'], $answer);
         $manager->persist($answer);
     }
     $manager->flush();
 }
 public function findLastByUser(User $user)
 {
     $start = new \DateTime();
     $start->sub(new \DateInterval('P35D'));
     $answers = $this->getEntityManager()->createQueryBuilder()->select('a')->from(Answer::class, 'a')->where('a.user = :user')->andWhere('a.createdAt > :start')->setParameter('user', $user)->setParameter('start', $start)->getQuery()->getResult();
     $userPetitions = $this->getEntityManager()->getRepository(Petition::class)->findByUser($user);
     foreach ($userPetitions as $petition) {
         $answer = new Answer();
         $answer->setPetitionId($petition->getId());
         $answers[] = $answer;
     }
     return $answers;
 }
 public function getPetitionId()
 {
     $this->__load();
     return parent::getPetitionId();
 }