Exemple #1
0
 /**
  * @param Connection $connection
  */
 public function sendConnectionCreatedEmail(Connection $connection)
 {
     $emailData = [['recipient' => $connection->getFluentSpeaker(), 'partner' => $connection->getLearner()], ['recipient' => $connection->getLearner(), 'partner' => $connection->getFluentSpeaker()]];
     foreach ($emailData as $data) {
         $parameters = ['connection' => $connection, 'recipient' => $data['recipient'], 'partner' => $data['partner']];
         $message = \Swift_Message::newInstance()->setSubject('Fikakompis/ Musikkompis från Kompisbyrån')->setFrom('*****@*****.**')->setReplyTo('*****@*****.**')->setTo($data['recipient']->getEmail(), $data['recipient']->getName())->setBody($this->templating->render('email/connectionCreated.html.twig', $parameters), 'text/html')->addPart($this->templating->render('email/connectionCreated.txt.twig', $parameters), 'text/plain');
         $this->mailer->send($message);
     }
 }
 /**
  * @Route("/{id}", name="admin_start", defaults={"id": null})
  */
 public function indexAction(Request $request, City $city = null)
 {
     $manager = $this->getDoctrine()->getManager();
     if ($request->isMethod('POST')) {
         $learnerConnectionRequest = $this->getConnectionRequestRepository()->find($request->request->getInt('learner'));
         $fluentSpeakerConnectionRequest = $this->getConnectionRequestRepository()->find($request->request->getInt('fluentSpeaker'));
         if ($this->getConnectionRepository()->findForUsers($learnerConnectionRequest->getUser(), $fluentSpeakerConnectionRequest->getUser())) {
             $this->addFlash('error', sprintf('Personerna %s och %s har redan kopplats ihop tidigare', $learnerConnectionRequest->getUser()->getName(), $fluentSpeakerConnectionRequest->getUser()->getName()));
         } else {
             $connection = new Connection($this->getUser());
             $connection->setLearner($learnerConnectionRequest->getUser());
             $connection->setFluentSpeaker($fluentSpeakerConnectionRequest->getUser());
             $connection->setCity($learnerConnectionRequest->getCity());
             $connection->setFluentSpeakerComment($fluentSpeakerConnectionRequest->getComment());
             $connection->setLearnerComment($learnerConnectionRequest->getComment());
             $manager->persist($connection);
             $manager->remove($learnerConnectionRequest);
             $manager->remove($fluentSpeakerConnectionRequest);
             $manager->flush();
             $this->get('event_dispatcher')->dispatch(DomainEvents::CONNECTION_CREATED, new ConnectionCreatedEvent($connection));
             $this->addFlash('info', sprintf('En koppling skapades melland %s och %s', $learnerConnectionRequest->getUser()->getName(), $fluentSpeakerConnectionRequest->getUser()->getName()));
         }
         return $this->redirect($this->generateUrl('admin_start'));
     }
     if (!$city) {
         $city = $this->getCityRepository()->findAll()[0];
     }
     $learners = $this->getConnectionRequestRepository()->findBy(['wantToLearn' => true, 'city' => $city]);
     $fluentSpeakers = $this->getConnectionRequestRepository()->findBy(['wantToLearn' => false, 'city' => $city]);
     $cities = $this->getCityRepository()->findAll();
     $parameters = ['categories' => $this->getCategoryRepository()->findAll(), 'learners' => $learners, 'fluentSpeakers' => $fluentSpeakers, 'cities' => $cities, 'city' => $city];
     return $this->render('admin/default/index.html.twig', $parameters);
 }
 /**
  * {@inheritDoc}
  */
 public function getTranslatedTo()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getTranslatedTo', array());
     return parent::getTranslatedTo();
 }
Exemple #4
0
 /**
  * @param ObjectManager $manager
  */
 protected function loadConnections(ObjectManager $manager)
 {
     foreach (range(1, 25) as $i) {
         $connection = new Connection();
         $connection->setCity($this->getReference('city-1'));
         $connection->setFluentSpeaker($this->getReference('user-fluentspeaker'));
         $connection->setLearner($this->getReference('user-learner'));
         $manager->persist($connection);
     }
 }