original_string: protected function prepareReviewsProduct(array &$reviews)
      {
          if (!empty($reviews)) {
  
              $users = array();
              foreach ($reviews as $review) {
                  $users[] = $review['user_id'];
              }
  
              $ratings = null;
  
              if (!empty($users)) {
                  $ratings = $this->rating->getByUser($this->data_product['product_id'], $users);
              }
  
              foreach ($reviews as &$review) {
  
                  $rating = array('rating' => 0);
  
                  if (isset($ratings[$review['user_id']]['rating'])) {
                      $rating['rating'] = $ratings[$review['user_id']]['rating'];
                  }
  
                  $review['rating'] = $rating['rating'];
                  $review['rating_formatted'] = $this->render('common/rating/static', array('rating' => $rating));
              }
          }
      }
code: protected function prepareReviewsProduct(array &$reviews)
      {
          if (!empty($reviews)) {
  
              $users = array();
              foreach ($reviews as $review) {
                  $users[] = $review['user_id'];
              }
  
              $ratings = null;
  
              if (!empty($users)) {
                  $ratings = $this->rating->getByUser($this->data_product['product_id'], $users);
              }
  
              foreach ($reviews as &$review) {
  
                  $rating = array('rating' => 0);
  
                  if (isset($ratings[$review['user_id']]['rating'])) {
                      $rating['rating'] = $ratings[$review['user_id']]['rating'];
                  }
  
                  $review['rating'] = $rating['rating'];
                  $review['rating_formatted'] = $this->render('common/rating/static', array('rating' => $rating));
              }
          }
      }
code_tokens: protected function prepareReviewsProduct ( array & $ reviews ) { if ( ! empty ( $ reviews ) ) { $ users = array ( ) ; foreach ( $ reviews as $ review ) { $ users [ ] = $ review [ 'user_id' ] ; } $ ratings = null ; if ( ! empty ( $ users ) ) { $ ratings = $ this -> rating -> getByUser ( $ this -> data_product [ 'product_id' ] , $ users ) ; } foreach ( $ reviews as & $ review ) { $ rating = array ( 'rating' => 0 ) ; if ( isset ( $ ratings [ $ review [ 'user_id' ] ] [ 'rating' ] ) ) { $ rating [ 'rating' ] = $ ratings [ $ review [ 'user_id' ] ] [ 'rating' ] ; } $ review [ 'rating' ] = $ rating [ 'rating' ] ; $ review [ 'rating_formatted' ] = $ this -> render ( 'common/rating/static' , array ( 'rating' => $ rating ) ) ; } } }
docstring: Prepare an array of reviews
  @param array $reviews
docstring_tokens: Prepare an array of reviews