public function getUpcomingEvents(Event $event, $limit = false) { $countryId = $event->getCountry() ? $event->getCountry()->getId() : false; $stateId = $event->getState() ? $event->getState()->getId() : false; $qb = $this->createQueryBuilder('e')->where('e.eventDate > :event_date')->andWhere('e.eventDate > :current_date')->setParameter('event_date', $event->getEventDate(), \Doctrine\DBAL\Types\Type::DATETIME)->setParameter('current_date', new \DateTime(), \Doctrine\DBAL\Types\Type::DATETIME); if ($stateId) { $qb->join('e.state', 's')->andWhere('s.id = :state_id')->setParameter('state_id', $stateId); } elseif ($countryId) { $qb->join('e.country', 'c')->andWhere('c.id = :country_id')->setParameter('country_id', $countryId); } if ($limit) { $qb->setMaxResults($limit); } return $qb->getQuery()->getResult(); }
/** * @Route("/remove/{id}", name="remove_profile_event", requirements={"id" = "\d+"}) * @ParamConverter("Event", class="ConnectionEventBundle:Event") * @param Event $event * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function removeAction(Event $event) { if (!($user = $this->getUser())) { throw new AccessDeniedException(); } if ($event->getUser()->getId() != $user->getId()) { throw new AccessDeniedException(); } $em = $this->getDoctrine()->getManager(); $em->remove($event); $em->flush(); return $this->redirect($this->generateUrl('edit_user_profile', array('tab' => 'events'))); }
/** * {@inheritDoc} */ public function setVenue($venue) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setVenue', array($venue)); return parent::setVenue($venue); }
protected function execute(InputInterface $input, OutputInterface $output) { /* @var $em \Doctrine\ORM\EntityManager */ $em = $this->getContainer()->get('doctrine')->getManager(); $userRepo = $em->getRepository('ConnectionUserBundle:User'); $countryRepo = $em->getRepository('ConnectionCoreBundle:Country'); $stateRepo = $em->getRepository('ConnectionCoreBundle:State'); $genderRepo = $em->getRepository('ConnectionUserBundle:Profile\\Gender'); $eventCategoryRepo = $em->getRepository('ConnectionEventBundle:Category'); $userManager = $this->getContainer()->get('fos_user.user_manager'); $rootDir = $this->getContainer()->get('kernel')->getRootDir() . '/../web/'; $userArray = $this->_getUserArray(); foreach ($userArray as $userItem) { $output->writeln('Creating user: '******'username']); $user = $userRepo->findOneBy(array('username' => $userItem['username'])); if ($user) { $em->remove($user); $em->flush(); } $email = strtolower($userItem['username']) . '@mail.com'; $user = new User(); $user->setUsername($userItem['username']); $user->setEmail($email); $user->setPlainPassword('123456'); $user->setEnabled(true); $profile = new Profile(); $gender = $genderRepo->find($userItem['profile']['gender']); $profile->setGender($gender); $seek = $genderRepo->find($userItem['profile']['seek']); $profile->setSeek($seek); $profile->setBirthdate($userItem['profile']['birthdate']); $country = $countryRepo->findOneBy(array('iso' => $userItem['profile']['country'])); $profile->setCountry($country); $state = $stateRepo->findOneBy(array('name' => $userItem['profile']['state'])); $profile->setState($state); $user->setProfile($profile); $em->persist($user); $em->flush(); foreach ($userItem['events'] as $eventItem) { $event = new Event(); $event->setContactName($userItem['username']); $event->setTitle($eventItem['title']); $event->setDescription($eventItem['description']); $event->setEventDate($eventItem['date']); $event->setEmail($email); $event->setPhone('12345678'); $event->setUser($user); $collection = new ArrayCollection(); foreach ($eventItem['categories'] as $categoryItem) { $category = $eventCategoryRepo->findOneBy(array('name' => $categoryItem)); $collection->add($category); } $event->setCategory($collection); $image = new Image(); $imageName = $userItem['username'] . 'Event.jpeg'; $imagePath = 'uploads/user/event/' . $user->getId(); $pathFrom = $rootDir . 'uploads/user/fixtures/' . $imageName; $pathTo = $rootDir . $imagePath . '/' . $imageName; mkdir($rootDir . $imagePath); copy($pathFrom, $pathTo); $image->setName($imageName); $image->setPath('/' . $imagePath . '/' . $imageName); $event->setImage($image); $em->persist($event); $em->flush(); } $gallery = $user->getGalleries()->first(); $gallery->setUser($user); $gallery->setTitle('Profile Images'); $gallery->setDefault(true); $image = new Image(); $imageName = $userItem['username'] . '.jpeg'; $imagePath = 'uploads/user/profile/' . $user->getId(); $pathFrom = $rootDir . 'uploads/user/fixtures/' . $imageName; $pathTo = $rootDir . $imagePath . '/' . $imageName; mkdir($rootDir . $imagePath); copy($pathFrom, $pathTo); $image->setName($imageName); $image->setPath('/' . $imagePath . '/' . $imageName); $profile->setAvatar('/' . $imagePath . '/' . $imageName); $image->setGallery($gallery); $collection = new ArrayCollection(); $collection->add($image); $gallery->setImages($collection); $em->persist($gallery); $em->flush(); } }
/** * @Route("/event/comments/{id}", name="admin_event_comments_view", requirements={"id" = "\d+"}) * @Template() * @ParamConverter("Event", class="ConnectionEventBundle:Event") */ public function commentsViewAction(Event $event) { $comments = $event->getComments(); return array('comments' => $comments, 'headline' => "Comments"); }