示例#1
0
 /**
  * @return PubRepository
  * @throws \DataBaseException
  * @throws \Exception
  */
 public function getPubs()
 {
     $pubRepository = $this->pubDAL->getPubs();
     $beerRepository = $this->beerDAL->getBeers();
     $pubBeers = $this->getPubBeers();
     // Goes through the pubs..
     foreach ($pubRepository->get() as $pub) {
         // and each beer..
         foreach ($beerRepository->get() as $beer) {
             // lastly each "post" in the relational table
             foreach ($pubBeers->get() as $pubBeer) {
                 // checks for a connection between beer and pub
                 if ($pub->getId() === $pubBeer->getPubId() && $beer->getId() === $pubBeer->getBeerId()) {
                     $beer->setPrice($pubBeer->getPrice());
                     $pub->addBeer($beer);
                 }
             }
         }
     }
     return $pubRepository;
 }
示例#2
0
 /**
  * @return PubRepository
  * @throws \DataBaseException
  */
 public function getPubs()
 {
     return $this->pubDAL->getPubs();
 }