Example #1
0
 public function handle(\Voetbal\Command\AssociationAdd $command)
 {
     $entityManager = Service::getEntityManager();
     // check if name not exists in repository
     $associationRepos = $entityManager->getRepository("Voetbal\\DAO\\Association");
     $oDAOAssociation = $associationRepos->findOneBy(array('name' => $command->getName()));
     if ($oDAOAssociation !== null) {
         throw new \Exception("de bondsnaam " . $command->getName() . " bestaat al", E_ERROR);
     }
     $oAssociation = new Association($command->getName());
     $oAssociation->setDescription($command->getDescription());
     $oDAOParentAssociation = null;
     $oParentAssociation = $command->getParent();
     if ($oParentAssociation !== null) {
         $oDAOParentAssociation = $associationRepos->findOneBy(array('name' => $oParentAssociation->getName()));
         if ($oDAOParentAssociation === null) {
             throw new \Exception("de hoofdbond bestaat niet", E_ERROR);
         }
     }
     $oAssociation->setParent($oParentAssociation);
     $oDAOAssociation = new DAOAssociation();
     $oDAOAssociation->setName($oAssociation->getName());
     $oDAOAssociation->setDescription($oAssociation->getDescription());
     $oDAOAssociation->setParent($oDAOParentAssociation);
     $entityManager->persist($oDAOAssociation);
     $entityManager->flush();
     // return LeagueRepository::add( $oLeague );
     return $oAssociation;
 }
Example #2
0
 public function handle(\Voetbal\Command\LeagueAdd $command)
 {
     $oLeague = new League($command->getName(), $command->getAbbreviation());
     // echo "handled command addseason, should be written tot db" . PHP_EOL;
     $oDAOLeague = new DAOLeague();
     $oDAOLeague->setName($oLeague->getName());
     $oDAOLeague->setAbbreviation($oLeague->getAbbreviation());
     $entityManager = Service::getEntityManager();
     $entityManager->persist($oDAOLeague);
     $entityManager->flush();
     // return LeagueRepository::add( $oLeague );
     return $oLeague;
 }
Example #3
0
 public function handle(\Voetbal\Command\SeasonAdd $command)
 {
     $oSeason = new Season($command->getName(), $command->getPeriod());
     // echo "handled command addseason, should be written tot db" . PHP_EOL;
     $oDAOSeason = new DAOSeason();
     $oDAOSeason->setName($oSeason->getName());
     $oDAOPeriod = new DAOPeriod();
     $oDAOPeriod->setStartDateTime(new \DateTime("@" . $oSeason->getStartDate()->getTimestamp()));
     $oDAOPeriod->setEndDateTime(new \DateTime("@" . $oSeason->getEndDate()->getTimestamp()));
     $oDAOSeason->setPeriod($oDAOPeriod);
     $entityManager = Service::getEntityManager();
     $entityManager->persist($oDAOSeason);
     $entityManager->flush();
     // return SeasonRepository::add( $oSeason );
     return $oSeason;
 }
Example #4
0
try {
    $command = new Command\AssociationAdd(new Association\Name("F.I.F.A."));
    $command->setDescription(new Association\Description("wereld voetbalbond"));
    $oAssociationWorld = Service::getBus()->handle($command);
    $command = new Command\AssociationAdd(new Association\Name("U.E.F.A."));
    $command->setDescription(new Association\Description("europese voetbalbond"));
    $command->setParent($oAssociationWorld);
    $oAssociationEurope = Service::getBus()->handle($command);
    $command = new Command\SeasonAdd(new Season\Name("2016/2017"), new Period(Carbon::create(2016, 9, 1, 0), Carbon::create(2017, 7, 1, 0)));
    $oSeason = Service::getBus()->handle($command);
    $command = new Command\LeagueAdd(new League\Name("eredivisie"), new League\Abbreviation("ere"));
    $oLeague = Service::getBus()->handle($command);
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}
return;
// @TODO competitionadd-command should check if the combination does not exists, entitymanager should be injected in the command
$command = new Command\CompetitionAdd($oLeague, $oSeason);
$command->putAssociation();
$command->putPromotionRule();
$command->putNrOfMinutesGame();
$command->putNrOfMinutesExtraTime();
$command->putWinPointsAfterGame();
$command->putWinPointsAfterExtraTime();
$command->putWinPointsAfterExtraTime();
// @TODO $command->putExternId();, should maybe go through an import object to check uniqueness
$oCompetition = Service::getBus()->handle($command);
/*Public                    deze eigenschapp zou een eigen klasse moeten hebben CompetitionPublish


ExternId*/