/** * @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) { $em = $this->em; //create empty entity licence $licence = new LicencesTeams(); $em->persist($licence); $em->flush(); //set data to create licence $idLicence = str_pad($licence->getId(), 5, 0, STR_PAD_LEFT); $idClub = str_pad($club->getId(), 3, 0, STR_PAD_LEFT); $jd = $this->getJulianDate('now'); // cretae number licence and flush it $licence->setLicence(self::PREFIX_LICENCE . $idClub . $idLicence . $jd); $em->persist($licence); $em->flush(); return $licence; }
/** * @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; }
/** * @return array */ public function toArray() { return ['weezevent_api_log_id' => $this->getId(), 'user_id' => $this->getUser() ? $this->getUser()->getId() : null, 'api_username' => $this->apiUsername, 'api_password' => $this->apiPassword, 'api_key' => $this->getApiKey(), 'date_register' => $this->getDateRegister()->format('Y-m-d H:i:s'), 'club_id' => $this->club ? $this->club->getId() : null]; }