public function validateMatch(\Club\RankingBundle\Entity\Ranking $ranking, $club_match) { try { $this->ranking = $ranking; $this->match = $club_match->getMatch(); $this->validateGender($this->match); if ($ranking->getInviteOnly()) { if (!$ranking->canPlay($user)) { throw new \Exception($this->translator->trans('%user% is not allowed to play in this league.', array('%user%' => $user->getName()))); } } $this->validateSets($this->match); $this->validateRules($ranking); } catch (\Exception $e) { $club_match->setError($e->getMessage()); } }