isUsingBundle() public method

Check that owner is using bundles
public isUsingBundle ( Bundle $bundle ) : boolean
$bundle Bundle
return boolean
Beispiel #1
0
 /**
  * @param Bundle    $bundle
  * @param Developer $developer
  */
 public function manageBundleRecommendation(Bundle $bundle, Developer $developer)
 {
     if ($developer->isUsingBundle($bundle)) {
         $activity = $this->entityManager->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Activity')->findOneBy(array('type' => Activity::ACTIVITY_TYPE_RECOMMEND, 'bundle' => $bundle, 'developer' => $developer));
         if ($activity) {
             $this->entityManager->remove($activity);
         }
         $bundle->removeRecommender($developer);
     } else {
         $activity = new Activity();
         $activity->setType(Activity::ACTIVITY_TYPE_RECOMMEND);
         $activity->setBundle($bundle);
         $activity->setDeveloper($developer);
         $this->entityManager->persist($activity);
         $bundle->addRecommender($developer);
     }
     $this->entityManager->persist($bundle);
     $this->entityManager->flush();
 }