Exemplo n.º 1
0
 /**
  * Creates a Cart object based on a DB row.
  *
  * @param array $row The DB row containing cart data.
  * @return \VeryGoodTrip\Domain\Cart
  */
 protected function buildDomainObject($row)
 {
     $cart = new Cart();
     $cart->setId($row['cart_id']);
     $cart->setUser($this->userDAO->findById($row['user_id']));
     $cart->setTrip($this->tripDAO->find($row['trip_id']));
     return $cart;
 }
Exemplo n.º 2
0
 /**
  * Creates a Review object based on a DB row.
  *
  * @param array $row The DB row containing Review data.
  * @return \VeryGoodTrip\Domain\Review
  */
 protected function buildDomainObject($row)
 {
     $review = new Review();
     $review->setId($row['review_id']);
     $review->setContent($row['review_content']);
     $review->setRating($row['review_rating']);
     if (array_key_exists('review_id', $row)) {
         //Find and set the associated trip
         $tripId = $row['trip_id'];
         $trip = $this->tripDAO->find($tripId);
         $review->setTrip($trip);
     }
     if (array_key_exists('user_id', $row)) {
         // Find and set the associated author
         $userId = $row['user_id'];
         $user = $this->userDAO->find($userId);
         $review->setUser($user);
     }
     return $review;
 }