Knp\Bundle\KnpBundlesBundle\Manager\BundleManager::manageBundleRecommendation PHP Method

manageBundleRecommendation() public method

public manageBundleRecommendation ( Bundle $bundle, Developer $developer )
$bundle Knp\Bundle\KnpBundlesBundle\Entity\Bundle
$developer Knp\Bundle\KnpBundlesBundle\Entity\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();
    }