private function processEvent($event) { $eventEntity = new Event(); $eventEntity->setTitle($event['title']); $eventEntity->setImageUrl($event['imageUrl']); return $eventEntity; }
/** * Lists all races and payment amounts for a specific club. * * @Route("/event/{event}/billing/{club}", name="billing_show") * @Method("GET") */ public function showAction(Event $event, Club $club) { $em = $this->getDoctrine()->getManager(); /** @var RaceRepository $raceRepo */ $raceRepo = $em->getRepository('AppBundle:Race'); // $paid = $repo->findBy(array('event' => $event->getId(), 'club' => $club->getId())); $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId()); $billingPositions = array(); $total = 0.0; /** @var Race $race */ foreach ($races as $race) { $price = $race->getPricePerStarter(); /** @var RaceSection $section */ foreach ($race->getSections() as $section) { /** @var Registration $registration */ foreach ($section->getRegistrations() as $registration) { /** @var Club $myClub */ $myClub = $registration->getTeam()->getClub(); if ($club->getId() == $myClub->getId()) { // TODO handle de-registered and those from other races if (array_key_exists($race->getId(), $billingPositions)) { $billingPositions[$race->getId()]['teams'] += 1; $billingPositions[$race->getId()]['amount'] += $price; } else { $billingPositions[$race->getId()] = array('teams' => 1, 'amount' => $price, 'race' => $race); } $total += $price; } } } } return $this->render('billing/show.html.twig', array('club' => $club, 'event' => $event, 'positions' => $billingPositions, 'rr' => $raceRepo, 'total' => $total)); }
/** * Find recommended concerts * * @param Event $event Event * @param User $user User * * @return [] */ public function findRecommendedConcerts(Event $event, User $user) { $eventRepository = $this->entityManager->getRepository('AppBundle:Event'); $genreRepository = $this->entityManager->getRepository('AppBundle:Genre'); $groupRepository = $this->entityManager->getRepository('AppBundle:Group'); $eventGenres = []; $eventGroups = []; /** @var EventGroup $eventGroup */ foreach ($event->getEventGroups()->getValues() as $eventGroup) { $groupGenres = $eventGroup->getGroup()->getGroupGenres(); // Get groups from event $eventGroups[] = $eventGroup->getGroup(); /** @var GroupGenre $groupGenre */ foreach ($groupGenres as $groupGenre) { // Get genres from event $eventGenres[] = $groupGenre->getGenre(); } } // Get user bookmarked genres and groups $userBookmarkedGenres = $genreRepository->findGenresByUser($user); $userBookmarkedGroups = $groupRepository->findGroupsByUser($user); // Combine event genres and groups with user bookmarked genres and groups $recommendedGenres = array_merge($userBookmarkedGenres, $eventGenres); $recommendedGroups = array_merge($userBookmarkedGroups, $eventGroups); $events = $eventRepository->findAllActiveByGenresAndGroupsWithLimit($recommendedGenres, $recommendedGroups, Event::NUMBER); foreach ($events as $key => $element) { if ($event === $element) { unset($events[$key]); } } return $events; }
/** * @Route("/newevent", name="create_event") * @Template */ public function neweventAction(Request $request) { $em = $this->getDoctrine()->getManager(); $eventuserRepository = $em->getRepository('AppBundle:EventUser'); $eventRepository = $em->getRepository('AppBundle:Event'); $temp_event = new Event(); $temp_event->setUser($this->getUser()); $temp_event->setIsDemo(false); $form = $this->createForm(new EventType(), $temp_event); if ($request->isMethod("POST")) { $form->handleRequest($request); if ($form->isValid()) { $number = $temp_event->getHostNumber(); if (strpos($number, '1') !== 0) { //making sure that all numbers have 1 as fisrt int $number = "1" . $number; $temp_event->setHostNumber($number); } $this->getDoctrine()->getManager()->persist($temp_event); $this->getDoctrine()->getManager()->flush(); //$searchNumber = $temp_event->getTwilioNumber(); //$searchEvent = $eventRepository->getEventFromNumber($searchNumber); $eventuserRepository->makeHostAdmin($temp_event, $temp_event->getHostNumber()); //maybe change to superadmin in the furture return $this->redirectToRoute('user_events'); } } return ["form" => $form->createView(), "onHomepage" => false]; }
/** * To string * * @return string */ public function __toString() { $result = 'New EventGroup'; if (null !== $this->event && null !== $this->group) { $result = $this->event->getName() . ' - ' . $this->group->getName(); } return $result; }
/** * Displays a form to create a new Event entity. * * @Route("/new", name="event_new") * @Method("GET") * @Template("AppBundle:Shared:new.html.twig") */ public function newAction() { $entity = new Event(); $today = date_create(); $entity->setDatetime($today); $form = $this->createCreateForm($entity); return array('entity' => $entity, 'form' => $form->createView()); }
public function getNewlyAddedSongs($pingedat, Event $event) { $newsongs = []; $queryBuilder = $this->createQueryBuilder('s')->where('s.event = :event AND s.createdAt >= :time')->setParameters(['event' => $event->getId(), 'time' => $pingedat]); $query = $queryBuilder->getQuery(); $newsongs = $query->getResult(); return $newsongs; }
public static function fromDomainEvent(DomainEvent $domainEvent) { $dbEvent = new DbEvent(); $dbEvent->setId($domainEvent->getId()); $dbEvent->setTitle($domainEvent->getTitle()); $dbEvent->setDateWithTimeRange(DbDateWithTimeRangeFactory::fromDomainDateWithRimeRange($domainEvent->getScheduledDateWithTimeRange())); return $dbEvent; }
/** * @param DbEvent $dbEvent * @return DomainEvent * @throws \CoreDomain\Exception\DomainRuleException */ public static function fromDbEvent(DbEvent $dbEvent) { $domainEvent = new DomainEvent(new UUId($dbEvent->getId()), new String($dbEvent->getTitle())); $dateWithTimeRange = DomainDateWithTimeRangeFactory::fromDateWithTimeRangeEmbeddable($dbEvent->getDateWithTimeRange()); if ($dateWithTimeRange) { $domainEvent->schedule($dateWithTimeRange); } return $domainEvent; }
/** * Check if the total paid is equal to the total of open payments * * @param Event $event The event to inspect. * @param Club $club The club for that the check should be done. * @return bool <tt>true</tt> if everything was paid */ public function hasPaidEverything(Event $event, Club $club) { // search for all billings $billings = $this->findBy(array('event' => $event->getId(), 'club' => $club->getId())); $totalPaid = 0.0; /** @var Billing $billing */ foreach ($billings as $billing) { $totalPaid += $billing->getEuro() + $billing->getCent() / 100.0; } $toPay = $this->getTotalToPay($event, $club); return 0 <= $toPay - $totalPaid; }
/** * Lists all Race entities. * * @Route("/event/{event}/races/{onlyThoseThatCanBeStarted}", name="race_index") * @Method("GET") */ public function indexAction(Event $event, $onlyThoseThatCanBeStarted = false) { $em = $this->getDoctrine()->getManager(); /** @var RaceRepository $repo */ $repo = $em->getRepository('AppBundle:Race'); if ($onlyThoseThatCanBeStarted) { $races = $repo->getAllRacesThatHaveRegistrations($event->getId()); } else { $races = $event->getRaces(); } return $this->render('race/index.html.twig', array('races' => $races, 'event' => $event, 'rr' => $repo, 'filtered' => $onlyThoseThatCanBeStarted)); }
/** * Finds and displays a Event entity. * * @Route("/{id}", name="event_show") * @Method({"GET", "POST"}) */ public function showAction(Event $event, Request $request) { $email = new Email(); $form = $this->createFormBuilder($email)->add('email', TextType::class)->add('submit', SubmitType::class, array('label' => 'Add attendee'))->getForm(); $form->handleRequest($request); if ($form->isSubmitted()) { $data = $form->getData()->getEmail(); $user = $usr = $this->get('security.context')->getToken()->getUser()->getUsername(); $message = \Swift_Message::newInstance()->setSubject('New invitation form ' . $user)->setFrom(array('*****@*****.**' => 'Anonymous Gift'))->setTo($data)->setBody($this->renderView('event/email.html.twig', array('event' => $event)), 'text/html'); $this->get('mailer')->send($message); $this->get('session')->getFlashBag()->add('info', 'invitation to "' . $data . '" has been sent'); return $this->redirectToRoute('event_show', array('id' => $event->getId()), 301); } return $this->render('event/show.html.twig', array('event' => $event, 'form' => $form->createView())); }
/** * Creates a new Event entity. * * @Route("/events/inscription/{id}/new", name="inscription_event_create") * @Method("POST") * @Template("AppBundle:Events:newInscription.html.twig") * @param Event $event * @param Request $request * @return array|\Symfony\Component\HttpFoundation\RedirectResponse */ public function createAction(Event $event, Request $request) { if ($event->getOpen()) { $inscription = new Inscription(); $form = $this->createForm(new InscriptionType(), $inscription, array('action' => $this->generateUrl('inscription_event_create', array('id' => $event->getId())), 'method' => 'POST')); $form->add('submit', 'submit', array('label' => 'S\'inscrire')); $form->handleRequest($request); if ($form->isValid()) { $inscription->setEvent($event); $em = $this->getDoctrine()->getManager(); $em->persist($inscription); $em->flush(); return $this->redirect($this->generateUrl('inscription_event', array('id' => $event->getId()))); } return array('inscription' => $inscription, 'form' => $form->createView()); } }
public function searchForFreeNumber(Event $event) { $now = new \DateTime(); $day = 24; $daybefore = $now->modify("+" . $day . " hours"); $eventEnd = $event->getEndTime(); //free any numbers associated with events that have ended $this->getEntityManager()->getRepository('AppBundle:Event')->freeNumbersFromPastEvents(); //after removing any keys linked to past events, check to see if any are free. $freenumbers = $this->createQueryBuilder('n')->where('n.event IS NULL AND n.isDemo = false AND n.expiration >= :endtime')->setParameters(['endtime' => $eventEnd])->getQuery()->getResult(); //return the first free numberObject if ($freenumbers) { return $freenumbers[0]; } else { return Null; } }
/** * @param Event $event * @param Constraint $constraint */ public function validate($event, Constraint $constraint) { $eventEndDate = $event->getDate()->format('Y-m-d H:i:s'); $eventEndDate = new \DateTime($eventEndDate); $eventEndDate->modify("+" . $event->getDuration() . " minutes")->format('Y-m-d H:i:s'); // Map result set to my Entity. $rsm = new ResultSetMapping(); $rsm->addEntityResult('AppBundle\\Entity\\Event', 'e'); $rsm->addFieldResult('e', 'termin', 'date'); $rsm->addFieldResult('e', 'dauer', 'duration'); // Using MySQL for better DateTime handling $query = $this->em->createNativeQuery("SELECT * FROM veranstaltung e\n WHERE e.termin < :endDate\n AND e.termin + INTERVAL e.dauer MINUTE > :startDate", $rsm); $query->setParameters(array("endDate" => $eventEndDate, 'startDate' => $event->getDate()->format('Y-m-d H:i:s'))); $overlappingEntities = $query->getResult(); /** @var $constraint HasNoDateOverlap */ if ($overlappingEntities) { $this->context->addViolation($constraint->message); } }
/** * Show overview of all startable races to start multiple at once. * * @Route("/event/{event}/start", name="race_start_all") * @Method("GET") * @Security("has_role('ROLE_REFEREE')") */ public function showAllAction(Request $request, Event $event) { $em = $this->getDoctrine()->getManager(); /** @var RaceRepository $repo */ $repo = $em->getRepository('AppBundle:Race'); $allRaces = $repo->getAllRacesThatHaveRegistrations($event->getId()); $races = array(); /** @var Race $race */ foreach ($allRaces as $race) { if (!$repo->isFinished($race)) { $races[] = $race; } } if (0 == count($races)) { $this->addFlash('error', 'Keine startbaren Rennen gefunden!'); $this->redirect($request->headers->get('referer')); } return $this->render('race/startAll.html.twig', array('races' => $races, 'event' => $event, 'rr' => $repo)); }
public function testSetGetValueTrimShot() { $this->event->setType(Event::TYPE_SHOT); // string to trim $this->event->setValue('A1'); $this->assertEquals('A1', $this->event->getValue()); // string with result to trim $this->event->setValue('A2|sunk'); $this->assertEquals('A2', $this->event->getValue()); // array to trim $this->event->setValue(["\t A3 \n", ' hit ']); $this->assertEquals('A3', $this->event->getValue()); }
/** * @Route("/", name="endpoint_input") * @Method("GET") * @Template() */ public function indexAction(Request $request) { $endpoint = $request->query->get('endpoint'); if ($endpoint !== 'input') { return array('success' => false, 'message' => 'Error: Invalid Endpoint Request!'); } $eventName = $request->query->get('eventName'); $eventValue = $request->query->get('eventValue'); if (!empty($eventName) && !empty($eventValue)) { $em = $this->getDoctrine()->getManager(); $entity = new Event(); $entity->setEventName($eventName); $entity->setEventValue($eventValue); $entity->setReferrerUrl($this->getRequest()->getUri()); $em->persist($entity); $em->flush(); return array('success' => true, 'message' => 'Success: Added a new Input Endpoint Request!'); } else { return array('success' => false, 'message' => 'Error: Invalid Endpoint Request!'); } return array('success' => false, 'message' => 'Error: Invalid Endpoint Request!'); }
/** * starts the timing for multiple race sections * * @Route("/api/timing/start/event/{event}", name="timing_start_all") * @Method("POST") */ public function startMultipleRaceSectionsAction(Request $request, Event $event) { $timeWithFractionSeconds = $this->getTimeWithFractionSeconds(); $sectionIDs = $request->get('sections'); if (is_null($sectionIDs)) { $this->addFlash('error', "Keine Abteilung ausgewählt zum starten!"); } else { $em = $this->getDoctrine()->getManager(); $sectionRepo = $em->getRepository('AppBundle:RaceSection'); foreach ($sectionIDs as $sID) { $section = $sectionRepo->find($sID); $this->markAsStarted($section, $sID, $em, $timeWithFractionSeconds); } $em->flush(); } return $this->redirectToRoute('race_index', array('event' => $event->getId())); }
/** * @param $event * * @return License[] */ public function findForEvent(Event $event) { if ('startDate' == $event->getLicenseField()) { $where = 'DATE_DIFF(CURRENT_DATE(), l.startDate) = ?1'; } else { $where = 'DATE_DIFF(l.endDate, CURRENT_DATE()) = ?1'; } $criteria = $this->createQueryBuilder('l')->where($where)->andWhere('l.licenseType = ?2')->setParameter('1', $event->getShiftDays())->setParameter('2', $event->getLicenseType()); if (null != $event->getAddonKey()) { $criteria->andWhere('l.addonKey = ?3')->setParameter('3', $event->getAddonKey()); } return $criteria->getQuery()->getResult(); }
/** * @Extra\Route("/announcements/{id}/implement", name="EventFromAnnouncement") * @Extra\Template("admin/raw-form.html.twig") * @Extra\ParamConverter */ public function eventFromAnnouncementAction(Request $request, Entity\Announcement $announcement) { $event = Entity\Event::fromAnnouncement($announcement); $this->get("doctrine.orm.entity_manager")->persist($event); $form = $this->createForm(EventFromAnnouncementType::class, $event); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $this->get("doctrine.orm.entity_manager")->persist($form->getData()); $this->get("doctrine.orm.entity_manager")->remove($announcement); $this->get("doctrine.orm.entity_manager")->flush(); $this->addFlash('success', 'Встреча создана'); } else { $this->addFlash('error', 'Не удалось создать встречу'); } return $this->redirectToRoute('AdminAnnouncements'); } return ['form' => $form->createView()]; }
/** * @param Request $request * @param string $uriEvent * @return Response * @throws \Exception * * @ApiDoc( * description="Update the event with the given uri", * requirements={ * { * "name"="uriEvent", * "dataType"="string", * "description"="The uri of the event", * } * }, * parameters={ * { * "name"="some_property", * "dataType"="string", * "required"=false, * "description"="Some property to update" * } * } * ) */ public function updateEventAction(Request $request, $uriEvent) { $rawEvent = $this->get('pmanager')->findById('public', 'calendarobject', $uriEvent); if ($rawEvent == null) { return $this->buildError('404', 'The event with the given uri could not be found.'); } $params = array(); $content = $request->getContent(); if (!empty($content)) { $params = json_decode($content, true); } $event = new Event(); $event->loadFromCalData($rawEvent->calendarData); foreach ($params as $name => $value) { $event->__set($name, $value); } $calendarBackend = new CalendarBackend($this->get('pmanager'), $this->generateUrl('event_read', [], true), $this->get('slugify')); $calendarBackend->updateCalendarObject($rawEvent->calendarid, $rawEvent->uri, $event->getVObject()->serialize()); return $this->buildResponse(['event' => 'updated']); }
/** * @param Event $event * @return CoordsCollection */ private function getAttackerShots(Event $event) { $shotEvents = $this->eventRepository->findForGameByTypeAndPlayer($event->getGame(), Event::TYPE_SHOT, $event->getPlayer()); $attackerShots = new CoordsCollection(); foreach ($shotEvents as $shotEvent) { $attackerShots->append($shotEvent->getValue()); } return $attackerShots; }
public function getLastNumberForEvent(Event $event) { $em = $this->getEntityManager(); $qb = $em->createQueryBuilder(); $qb->select('MAX(r.numberInEvent) maxNum')->from('AppBundle:Race', 'r')->orderBy('r.numberInEvent', 'DESC')->where($qb->expr()->eq('r.event', '?1'))->setParameter(1, $event->getId()); return (int) $qb->getQuery()->getSingleScalarResult(); }
protected function createDemoEvent() { $event = new Event(); $event->setDocumentname('Demo event'); $event->setDocumentdescription(''); $event->setEventenddate(new \DateTime('2016-12-27')); $event->setEventonline(true); $event->setEventregistrationenddate(new \DateTime('2015-11-25')); $event->setEventregistrationstartdate(new \DateTime('2015-11-24')); $event->setEventstartdate(new \DateTime('2016-12-27')); $event->setEventtype('012'); $event->setFriendlyurl('http://opendata.euskadi.eus/catalogo/-/evento/20151117142228/-faboo-/kulturklik/es/'); $event->setPhysicalurl('http://opendata.euskadi.eus/catalogo/-/contenidos/evento/20151117142228/es_def/index.shtml'); $event->setDataxml('http://opendata.euskadi.eus/contenidos/evento/20151117142228/es_def/data/es_r01dtpd151159c5ffe1a48b14ba55eb3c450a81360'); $event->setMetadataxml('http://opendata.euskadi.eus/contenidos/evento/20151117142228/r01Index/20151117142228-idxContent.xml'); return $event; }
/** * Update event from db * * @param EventForm $eventForm * @param Event $event * @param User $user */ public function saveEventOnUpdate(EventForm $eventForm, Event $event, User $user) { $groupRepository = $this->entityManager->getRepository('AppBundle:Group'); /** @var Event $event */ $event->setName($eventForm->getName())->setDescription($eventForm->getDescription())->setCountry($eventForm->getCountry())->setCity($eventForm->getCity())->setAddress($eventForm->getAddress())->setBeginAt($eventForm->getBeginAt())->setEndAt($eventForm->getEndAt())->setSlug($eventForm->getName())->setUpdatedBy($user); $this->entityManager->persist($event); $groups = $groupRepository->findGroupsByEvent($event); /** @var Group $groupElement */ foreach ($eventForm->getGroups() as $groupElement) { $group = $groupRepository->findOneBy(['slug' => $groupElement->getSlug()]); if (!in_array($group, $groups)) { $eventGroups = (new EventGroup())->setEvent($event)->setGroup($group); $this->entityManager->persist($eventGroups); } } $this->entityManager->flush(); }
public function checkForAdmin(Event $event, $number) { $admins = $event->getAccountManagers(); foreach ($admins as $value) { if (strpos($value, $number) !== false) { return true; } } return false; }
/** * Example response:<pre> * {"timestamp":"2016-11-11T16:21:16+0000"} # for chat * {"result":"miss"} # for shot</pre> * * @ApiDoc( * resource=true, * description="Create new event", * section="Event", * statusCodes={ * 201="Event created", * 400="Incorrect parameter provided", * 404="Game not found", * 409="Action not allow due to game flow restrictions" * } * ) * * @Tag(expression="'game-' ~ game.getId() ~ 'events'") * @Security("game.belongsToUser(user)") * @RequestParam( * name="type", * requirements=@Assert\Choice(callback = {"AppBundle\Entity\Event", "getTypes"}) * ) * @RequestParam(name="value", requirements=".*\S.*", allowBlank=false, default=true) * * @param ParamFetcher $paramFetcher * @param Game $game * @return Response */ public function postEventAction(ParamFetcher $paramFetcher, Game $game) { $event = new Event(); $event->setGame($game)->setPlayer($game->getPlayerNumber())->setType($paramFetcher->get('type'))->setValue($paramFetcher->get('value')); $data = null; switch ($event->getType()) { case Event::TYPE_CHAT: $event->applyCurrentTimestamp(); $data = ['timestamp' => $event->getTimestamp()]; break; case Event::TYPE_SHOT: $shotResult = $this->battleManager->getShotResult($event); $event->setValue([$event->getValue(), $shotResult]); $data = ['result' => $shotResult]; break; } $this->entityManager->persist($event); $this->entityManager->flush(); $view = $this->routeRedirectView('api_v1_get_game_event', ['game' => $game->getId(), 'event' => $event->getId()])->setData($data); return $this->handleView($view); }
/** * @param string $slug * * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response */ public function calendarReadAction($slug) { $where = Where::create('slug = $*', [$slug]); $calendars = $this->get('pmanager')->findWhere('public', 'calendar', $where); if ($calendars->count() == 0) { return $this->redirectToRoute('calendar_home'); } $calendar = $calendars->get(0); $ownCalendar = false; $tkn = $this->get('security.token_storage')->getToken(); if (!$tkn instanceof AnonymousToken) { $usr = $tkn->getUser(); $username = $usr->getUsernameCanonical(); if ($calendar->principaluri == 'principals/' . $username) { $ownCalendar = true; } } $where = Where::create('calendarid = $*', [$calendar->uid]); $rawEvents = $this->get('pmanager')->findWhere('public', 'calendarobject', $where); $events = []; foreach ($rawEvents as $raw) { $event = new Event(); foreach ($raw->extracted_data as $name => $value) { $event->__set($name, $value); } $event->slug = $raw->slug; $events[] = $event; } $exportUrl = $this->generateUrl('caldav', ['url' => 'calendars/' . substr($calendar->principaluri, 11) . '/' . $calendar->uri, 'export' => '']); return $this->render('browser/calendar_read.html.twig', array('calendar' => $calendar, 'ownCalendar' => $ownCalendar, 'events' => $events, 'exportUrl' => $exportUrl)); }
/** * {@inheritDoc} */ public function getOwner() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOwner', []); return parent::getOwner(); }