Example #1
0
 /**
  * @param array $data
  * @return Struct\Product\Vote
  */
 public function hydrate(array $data)
 {
     $struct = new Struct\Product\Vote();
     if (isset($data['__vote_id'])) {
         $struct->setId((int) $data['__vote_id']);
     }
     if (isset($data['__vote_name'])) {
         $struct->setName($data['__vote_name']);
     }
     if (isset($data['__vote_points'])) {
         $struct->setPoints((double) $data['__vote_points']);
     }
     if (isset($data['__vote_comment'])) {
         $struct->setComment($data['__vote_comment']);
     }
     if (isset($data['__vote_datum']) && $data['__vote_datum'] != '0000-00-00 00:00:00') {
         $struct->setCreatedAt(new \DateTime($data['__vote_datum']));
     }
     if (isset($data['__vote_email'])) {
         $struct->setEmail($data['__vote_email']);
     }
     if (isset($data['__vote_headline'])) {
         $struct->setHeadline($data['__vote_headline']);
     }
     if (isset($data['__vote_answer'])) {
         $struct->setAnswer($data['__vote_answer']);
     }
     if (isset($data['__vote_answer_date'])) {
         $struct->setAnsweredAt(new \DateTime($data['__vote_answer_date']));
     }
     return $struct;
 }
 /**
  * @param StoreFrontBundle\Struct\Product\Vote $vote
  * @return array
  */
 public function convertVoteStruct(StoreFrontBundle\Struct\Product\Vote $vote)
 {
     $data = array('id' => $vote->getId(), 'name' => $vote->getName(), 'headline' => $vote->getHeadline(), 'comment' => $vote->getComment(), 'points' => $vote->getPoints(), 'active' => true, 'email' => $vote->getEmail(), 'answer' => $vote->getAnswer(), 'datum' => '0000-00-00 00:00:00', 'answer_date' => '0000-00-00 00:00:00');
     if ($vote->getCreatedAt() instanceof \DateTime) {
         $data['datum'] = $vote->getCreatedAt()->format('Y-m-d H:i:s');
     }
     if ($vote->getAnsweredAt() instanceof \DateTime) {
         $data['answer_date'] = $vote->getAnsweredAt()->format('Y-m-d H:i:s');
     }
     $data['attributes'] = $vote->getAttributes();
     return $data;
 }