/** * @param Clubs $club * @return array * @throws \Exception */ public function getListEventClub(Clubs $club) { $listEventClub = $this->em->getRepository('FfjvBoBundle:Evenements')->findBy(['club' => $club]); $listEvents = []; foreach ($listEventClub as $evenements) { $keyEvent = $evenements->getStartDate()->format('Y-m-d_H:i:s') . '_ffjv'; $listEvents[$keyEvent] = $evenements; $listEvents[$keyEvent]['origin'] = self::EVENT_ORIGIN_FFJV; $listEvents[$keyEvent]['participants'] = '0'; } $apiLog = $club->getWeezeventApiLog(); if ($apiLog) { $api = $this->weezeventApi->setUser($club->getUser())->setAuthAccess($apiLog->getApiUsername(), $apiLog->getApiPassword(), $apiLog->getApiKey())->initConnection(); if (!$api) { throw new \Exception('Weez event ApiLog Failed'); } $apiEvents = $api->getEvents(true); foreach ($apiEvents['events'] as $event) { $keyEvent = str_replace(" ", "_", $event['date']['start']) . '_weezevent'; $listEvents[$keyEvent] = $this->convertApiEvent($event); } } krsort($listEvents); return $listEvents; }
/** * @param Clubs $club * @return LicencesTeams */ public function getNewLicences(Clubs $club) { $birthday = $club->getUser()->getBirthday(); $prefixLicence = $this->getJulianDate($birthday->format('Y-m-d H:i:s')); $em = $this->em; //create empty entity licence $licence = new LicencesClubs(); $em->persist($licence); $em->flush(); //set data to create licence $idLicence = str_pad($licence->getId(), 5, 0, STR_PAD_LEFT); $jd = $this->getJulianDate('now'); // create number licence and flush it $licence->setLicence(self::PREFIX_LICENCE . $prefixLicence . $idLicence . $jd); $em->persist($licence); $em->flush(); return $licence; }