Created
December 22, 2015 20:59
-
-
Save jclapp23/2ab9a2a2b6c29da28e22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getPlayerByLastNameAndSport($lastName,$teamStr,$sport){ | |
$doctrine = $this->getContainer()->get("doctrine"); | |
$em = $doctrine->getManager(); | |
$playerRepo = $em->getRepository("RotoRobotBundle:Player"); | |
$sportsLeagueRepo = $em->getRepository("RotoRobotBundle:SportsLeague"); | |
$teamRepo = $em->getRepository("RotoRobotBundle:Team"); | |
$sportsLeague = $sportsLeagueRepo->findOneBy(["name"=>$sport]); | |
$teamKeys = array( | |
"PHI"=>"PHI", | |
"ORL"=>"ORL", | |
"MIN"=>"MIN", | |
"DEN"=>"DEN", | |
"LAL"=>"LAL", | |
"DET"=>"DET", | |
"NY"=>"NYK", | |
"BOS"=>"BOS", | |
"SAC"=>"SAC", | |
"PHO"=>"PHO", | |
"GSW"=>"GSW", | |
"MIL"=>"MIL", | |
"CLE"=>"CLE", | |
"DAL"=>"DAL", | |
"SA"=>"SAS", | |
"BKN"=>"BRK", | |
"IND"=>"IND", | |
"NOR"=>"NOP", | |
"TOR"=>"TOR", | |
"POR"=>"POR", | |
"LAC"=>"LAC", | |
"MIA"=>"MIA", | |
"CHI"=>"CHI", | |
"CHA"=>"CHO", | |
"OKC"=>"OKC", | |
"WAS"=>"WAS", | |
"UTA"=>"UTA", | |
"MEM"=>"MEM", | |
"HOU"=>"HOU", | |
"ATL"=>"ATL", | |
); | |
if(!$teamStr = $teamKeys[$teamStr]) | |
echo "Team short name not mapped! Fix.." . "\n"; | |
$team = $teamRepo->findOneBy(["sportsLeague"=>$sportsLeague,"shortName"=>$teamStr]); | |
$res = $playerRepo | |
->createQueryBuilder("p") | |
->where("p.lastName = :last AND p.sportsLeague = :sportsLeague AND p.team = :team") | |
->setParameter("last", "$lastName") | |
->setParameter("sportsLeague", $sportsLeague) | |
->setParameter("team",$team) | |
->getQuery() | |
->getResult(); | |
if(count($res) == 1){ | |
return $res[0]; | |
}else{ | |
return false; | |
} | |
} | |
private function sendUnmatchedPlayerEmail($errorList){ | |
$mailer = $this->getContainer()->get("doctrine"); | |
$message = \Swift_Message::newInstance() | |
->setTo('[email protected]') | |
->setFrom('[email protected]') | |
->setSubject("Rotorobto->Fanduel Player Id Match Errrors") | |
; | |
$message->setBody(print_r($errorList),'text/html'); | |
$mailer->send($message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment