private function validateClubUser(User $user, $socialgroupid) { $relations = $user->getSocialRelations()->filter(function (SocialRelation $socialRelation) use($socialgroupid) { return $socialRelation->getGroup()->getId() == $socialgroupid; }); if (count($relations) == 0) { // The user is not a club user... throw new ValidationException("NOTCLUBUSER", "user="******"NEEDTOBERELATED", "user=" . $user->__toString()); } return $socialRelation->getGroup(); }
/** * @return Club */ public function getClub(User $user) { /* @var $rel SocialRelation */ foreach ($user->getSocialRelations()->toArray() as $rel) { if ($rel->getStatus() == SocialRelation::$MEM) { $teams = $rel->getGroup()->getTeams(); if ($teams->count() > 0) { return $teams->first()->getClub(); } } } return null; }