/**
  * @Route("/comment", name="Comment")
  */
 public function commentAction(Request $request)
 {
     $user = $this->getUser();
     $comment = new Comment();
     $now = new DateTime();
     $doodle_id = $request->get('id');
     $text = $request->get('comment');
     $doodle = $this->getDoctrine()->getRepository('AppBundle:Doodle')->find($doodle_id);
     $comment->setUser($user);
     $comment->setDoodle($doodle);
     $comment->setCreated($now);
     $comment->setText($text);
     if ($user) {
         $comment->setAuthor($user->username);
     } else {
         $comment->setAuthor('Anonymous');
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $data = ['message' => 'Success!', 'id' => $doodle_id, 'text' => $text];
     $response = new Response(json_encode(['response' => $data]));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 private function handleRequest(Comment $entity, Request $request)
 {
     $data = $request->getContent();
     if (isset($data['answer'])) {
         $entity->setAnswer($this->findAnswer($data['answer']));
     }
     if (isset($data['text'])) {
         $entity->setText($data['text']);
     }
     if (isset($data['created_by'])) {
         $entity->setCreatedBy($data['created_by']);
     }
 }
Example #3
0
 public function testSubmitValidData()
 {
     $formData = array('rating' => '3', 'text' => 'Some text');
     $form = $this->factory->create(CommentType::class);
     $object = new Comment();
     $object->setRating(3.0);
     $object->setText('Some text');
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
 public function commentAction(Request $request)
 {
     /* @var $user User */
     $user = $this->getUser();
     if (!$user) {
         throw new UnauthorizedHttpException('You must be logged in to comment.');
     }
     $decklist_id = filter_var($request->get('id'), FILTER_SANITIZE_NUMBER_INT);
     $decklist = $this->getDoctrine()->getRepository('AppBundle:Decklist')->find($decklist_id);
     $comment_text = trim($request->get('comment'));
     if ($decklist && !empty($comment_text)) {
         $comment_text = preg_replace('%(?<!\\()\\b(?:(?:https?|ftp)://)(?:((?:(?:[a-z\\d\\x{00a1}-\\x{ffff}]+-?)*[a-z\\d\\x{00a1}-\\x{ffff}]+)(?:\\.(?:[a-z\\d\\x{00a1}-\\x{ffff}]+-?)*[a-z\\d\\x{00a1}-\\x{ffff}]+)*(?:\\.[a-z\\x{00a1}-\\x{ffff}]{2,6}))(?::\\d+)?)(?:[^\\s]*)?%iu', '[$1]($0)', $comment_text);
         $mentionned_usernames = [];
         $matches = [];
         if (preg_match_all('/`@([\\w_]+)`/', $comment_text, $matches, PREG_PATTERN_ORDER)) {
             $mentionned_usernames = array_unique($matches[1]);
         }
         $comment_html = $this->get('texts')->markdown($comment_text);
         $now = new DateTime();
         $comment = new Comment();
         $comment->setText($comment_html);
         $comment->setDateCreation($now);
         $comment->setUser($user);
         $comment->setDecklist($decklist);
         $comment->setIsHidden(FALSE);
         $this->getDoctrine()->getManager()->persist($comment);
         $decklist->setDateUpdate($now);
         $decklist->setNbcomments($decklist->getNbcomments() + 1);
         $this->getDoctrine()->getManager()->flush();
         // send emails
         $spool = [];
         if ($decklist->getUser()->getIsNotifAuthor()) {
             if (!isset($spool[$decklist->getUser()->getEmail()])) {
                 $spool[$decklist->getUser()->getEmail()] = 'AppBundle:Emails:newcomment_author.html.twig';
             }
         }
         foreach ($decklist->getComments() as $comment) {
             /* @var $comment Comment */
             $commenter = $comment->getUser();
             if ($commenter && $commenter->getIsNotifCommenter()) {
                 if (!isset($spool[$commenter->getEmail()])) {
                     $spool[$commenter->getEmail()] = 'AppBundle:Emails:newcomment_commenter.html.twig';
                 }
             }
         }
         foreach ($mentionned_usernames as $mentionned_username) {
             /* @var $mentionned_user User */
             $mentionned_user = $this->getDoctrine()->getRepository('AppBundle:User')->findOneBy(array('username' => $mentionned_username));
             if ($mentionned_user && $mentionned_user->getIsNotifMention()) {
                 if (!isset($spool[$mentionned_user->getEmail()])) {
                     $spool[$mentionned_user->getEmail()] = 'AppBundle:Emails:newcomment_mentionned.html.twig';
                 }
             }
         }
         unset($spool[$user->getEmail()]);
         $email_data = array('username' => $user->getUsername(), 'decklist_name' => $decklist->getName(), 'url' => $this->generateUrl('decklist_detail', array('decklist_id' => $decklist->getId(), 'decklist_name' => $decklist->getNameCanonical()), UrlGeneratorInterface::ABSOLUTE_URL) . '#' . $comment->getId(), 'comment' => $comment_html, 'profile' => $this->generateUrl('user_profile_edit', [], UrlGeneratorInterface::ABSOLUTE_URL));
         foreach ($spool as $email => $view) {
             $message = \Swift_Message::newInstance()->setSubject("[thronesdb] New comment")->setFrom(array("*****@*****.**" => $user->getUsername()))->setTo($email)->setBody($this->renderView($view, $email_data), 'text/html');
             $this->get('mailer')->send($message);
         }
     }
     return $this->redirect($this->generateUrl('decklist_detail', array('decklist_id' => $decklist_id, 'decklist_name' => $decklist->getNameCanonical())));
 }
Example #5
0
 /**
  * @Route("dane/dodaj")
  */
 public function createData()
 {
     $mainCategory = new Category();
     $mainCategory->setCategory(null);
     $mainCategory->setActive(1);
     $mainCategory->setName('Główne');
     $em = $this->getDoctrine()->getManager();
     $em->persist($mainCategory);
     $em->flush();
     $foodCategory = new Category();
     $foodCategory->setCategory($mainCategory);
     $foodCategory->setActive(1);
     $foodCategory->setName('Żywność');
     $em = $this->getDoctrine()->getManager();
     $em->persist($foodCategory);
     $em->flush();
     $drugCategory = new Category();
     $drugCategory->setCategory($mainCategory);
     $drugCategory->setActive(1);
     $drugCategory->setName('Używki');
     $em = $this->getDoctrine()->getManager();
     $em->persist($drugCategory);
     $em->flush();
     $serviceCategory = new Category();
     $serviceCategory->setCategory($mainCategory);
     $serviceCategory->setActive(1);
     $serviceCategory->setName('Usługi');
     $em = $this->getDoctrine()->getManager();
     $em->persist($serviceCategory);
     $em->flush();
     $industryCategory = new Category();
     $industryCategory->setCategory($mainCategory);
     $industryCategory->setActive(1);
     $industryCategory->setName('Przemysł');
     $em = $this->getDoctrine()->getManager();
     $em->persist($industryCategory);
     $em->flush();
     $scienceCategory = new Category();
     $scienceCategory->setCategory($mainCategory);
     $scienceCategory->setActive(1);
     $scienceCategory->setName('Nauka, Edukacja');
     $em = $this->getDoctrine()->getManager();
     $em->persist($scienceCategory);
     $em->flush();
     $privateLessonCategory = new Category();
     $privateLessonCategory->setCategory($scienceCategory);
     $privateLessonCategory->setActive(1);
     $privateLessonCategory->setName('Korepetycje');
     $em = $this->getDoctrine()->getManager();
     $em->persist($privateLessonCategory);
     $em->flush();
     $beforeSchoolCategory = new Category();
     $beforeSchoolCategory->setCategory($scienceCategory);
     $beforeSchoolCategory->setActive(1);
     $beforeSchoolCategory->setName('Przedszkola');
     $em = $this->getDoctrine()->getManager();
     $em->persist($beforeSchoolCategory);
     $em->flush();
     $nurseryCategory = new Category();
     $nurseryCategory->setCategory($scienceCategory);
     $nurseryCategory->setActive(1);
     $nurseryCategory->setName('Żłobki');
     $em = $this->getDoctrine()->getManager();
     $em->persist($nurseryCategory);
     $em->flush();
     $wholePolandProvince = new Province();
     $wholePolandProvince->setActive(1);
     $wholePolandProvince->setName('Cała Polska');
     $em = $this->getDoctrine()->getManager();
     $em->persist($wholePolandProvince);
     $em->flush();
     $mazowieckieProvince = new Province();
     $mazowieckieProvince->setActive(1);
     $mazowieckieProvince->setName('Mazowieckie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($mazowieckieProvince);
     $em->flush();
     $dolnoslaskieProvince = new Province();
     $dolnoslaskieProvince->setActive(1);
     $dolnoslaskieProvince->setName('Dolnośląskie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($dolnoslaskieProvince);
     $em->flush();
     $warminskoMazurskieProvince = new Province();
     $warminskoMazurskieProvince->setActive(1);
     $warminskoMazurskieProvince->setName('Warmińsko-Mazurskie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($warminskoMazurskieProvince);
     $em->flush();
     $opolskieProvince = new Province();
     $opolskieProvince->setActive(1);
     $opolskieProvince->setName('Opolskie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($opolskieProvince);
     $em->flush();
     $slaskieProvince = new Province();
     $slaskieProvince->setActive(1);
     $slaskieProvince->setName('Śląskie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($slaskieProvince);
     $em->flush();
     $wroclawCity = new City();
     $wroclawCity->setProvince($dolnoslaskieProvince);
     $wroclawCity->setActive(1);
     $wroclawCity->setName('Wrocław');
     $em = $this->getDoctrine()->getManager();
     $em->persist($wroclawCity);
     $em->flush();
     $szczawnoZdrojCity = new City();
     $szczawnoZdrojCity->setProvince($dolnoslaskieProvince);
     $szczawnoZdrojCity->setActive(1);
     $szczawnoZdrojCity->setName('Szczawno-Zdrój');
     $em = $this->getDoctrine()->getManager();
     $em->persist($szczawnoZdrojCity);
     $em->flush();
     $stronieSlaskieCity = new City();
     $stronieSlaskieCity->setProvince($dolnoslaskieProvince);
     $stronieSlaskieCity->setActive(1);
     $stronieSlaskieCity->setName('Stronie Śląskie');
     $em = $this->getDoctrine()->getManager();
     $em->persist($stronieSlaskieCity);
     $em->flush();
     $jeleniaGoraCity = new City();
     $jeleniaGoraCity->setProvince($dolnoslaskieProvince);
     $jeleniaGoraCity->setActive(1);
     $jeleniaGoraCity->setName('Jelenia Góra');
     $em = $this->getDoctrine()->getManager();
     $em->persist($jeleniaGoraCity);
     $em->flush();
     $zmigrodCity = new City();
     $zmigrodCity->setProvince($dolnoslaskieProvince);
     $zmigrodCity->setActive(1);
     $zmigrodCity->setName('Żmigród');
     $em = $this->getDoctrine()->getManager();
     $em->persist($zmigrodCity);
     $em->flush();
     $sobotkaCity = new City();
     $sobotkaCity->setProvince($dolnoslaskieProvince);
     $sobotkaCity->setActive(1);
     $sobotkaCity->setName('Sobótka');
     $em = $this->getDoctrine()->getManager();
     $em->persist($sobotkaCity);
     $em->flush();
     $user = new User();
     $user->setProvince($dolnoslaskieProvince);
     $user->setCity($wroclawCity);
     $user->setActive(1);
     $user->setName('Robert');
     $user->setSurname('Rybiański');
     $user->setLogin('login');
     $user->setPassword(md5('password'));
     $user->setKey(md5(date('Y-m-d H:i:s') . 'password'));
     $user->setEmail('*****@*****.**');
     $user->setUrl('http://www.domena.pl/');
     $user->setPhone('226666666');
     $user->setStreet('Ulica 6');
     $user->setPostcode('66-666');
     $user->setDescription('Pierwszy użytkownik...');
     $user->setCommentNumber(13);
     $user->setCommentPositive7Days(2);
     $user->setCommentNeutral7Days(1);
     $user->setCommentNegative7Days(0);
     $user->setCommentPositive30Days(3);
     $user->setCommentNeutral30Days(1);
     $user->setCommentNegative30Days(1);
     $user->setCommentPositiveAllDays(10);
     $user->setCommentNeutralAllDays(2);
     $user->setCommentNegativeAllDays(1);
     $user->setCommentDate($dateTime = new \DateTime('2016-03-14 16:31:09'));
     $user->setIpAdded('127.0.0.1');
     $user->setDateAdded($dateTime);
     $user->setIpUpdated('127.0.0.1');
     $user->setDateUpdated($dateTime);
     $user->setIpLoged('127.0.0.1');
     $user->setDateLoged($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($user);
     $em->flush();
     $firm = new Firm();
     $firm->setUser($user);
     $firm->setProvince($dolnoslaskieProvince);
     $firm->setCity($wroclawCity);
     $firm->setActive(1);
     $firm->setVisible(1);
     $firm->setOrder(1);
     $firm->setName('Firma Pierwsza');
     $firm->setEmail('*****@*****.**');
     $firm->setUrl('http://www.firma.pl/');
     $firm->setPhone('226669999');
     $firm->setStreet('Ulica 9');
     $firm->setPostcode('66-999');
     $firm->setDescription('Pierwsza firma...');
     $firm->setMarkPrecision(5);
     $firm->setMarkContact(5);
     $firm->setMarkTime(5);
     $firm->setMarkPrice(5);
     $firm->setCommentNumber(15);
     $firm->setCommentPositive7Days(5);
     $firm->setCommentNeutral7Days(1);
     $firm->setCommentNegative7Days(0);
     $firm->setCommentPositive30Days(6);
     $firm->setCommentNeutral30Days(1);
     $firm->setCommentNegative30Days(1);
     $firm->setCommentPositiveAllDays(12);
     $firm->setCommentNeutralAllDays(2);
     $firm->setCommentNegativeAllDays(1);
     $firm->setCommentDate($dateTime = new \DateTime('2016-03-15 11:21:19'));
     $firm->setIpAdded('127.0.0.1');
     $firm->setDateAdded($dateTime);
     $firm->setIpUpdated('127.0.0.1');
     $firm->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firm);
     $em->flush();
     $firm = new Firm();
     $firm->setUser($user);
     $firm->setProvince($dolnoslaskieProvince);
     $firm->setCity($wroclawCity);
     $firm->setActive(1);
     $firm->setVisible(1);
     $firm->setOrder(1);
     $firm->setName('Firma Druga');
     $firm->setEmail('*****@*****.**');
     $firm->setUrl('http://www.firma2.pl/');
     $firm->setPhone('226688999');
     $firm->setStreet('Ulica 8');
     $firm->setPostcode('66-899');
     $firm->setDescription('Druga firma...');
     $firm->setMarkPrecision(4);
     $firm->setMarkContact(4);
     $firm->setMarkTime(4);
     $firm->setMarkPrice(4);
     $firm->setCommentNumber(10);
     $firm->setCommentPositive7Days(0);
     $firm->setCommentNeutral7Days(1);
     $firm->setCommentNegative7Days(0);
     $firm->setCommentPositive30Days(6);
     $firm->setCommentNeutral30Days(1);
     $firm->setCommentNegative30Days(1);
     $firm->setCommentPositiveAllDays(6);
     $firm->setCommentNeutralAllDays(3);
     $firm->setCommentNegativeAllDays(1);
     $firm->setCommentDate($dateTime = new \DateTime('2016-03-16 13:11:07'));
     $firm->setIpAdded('127.0.0.1');
     $firm->setDateAdded($dateTime);
     $firm->setIpUpdated('127.0.0.1');
     $firm->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firm);
     $em->flush();
     $firm = new Firm();
     $firm->setUser($user);
     $firm->setProvince($dolnoslaskieProvince);
     $firm->setCity($wroclawCity);
     $firm->setActive(1);
     $firm->setVisible(1);
     $firm->setOrder(1);
     $firm->setName('Firma Trzecia');
     $firm->setEmail('*****@*****.**');
     $firm->setUrl('http://www.firma3.pl/');
     $firm->setPhone('226677999');
     $firm->setStreet('Ulica 7');
     $firm->setPostcode('66-799');
     $firm->setDescription('Trzecia firma...');
     $firm->setMarkPrecision(3);
     $firm->setMarkContact(3);
     $firm->setMarkTime(3);
     $firm->setMarkPrice(3);
     $firm->setCommentNumber(5);
     $firm->setCommentPositive7Days(1);
     $firm->setCommentNeutral7Days(1);
     $firm->setCommentNegative7Days(0);
     $firm->setCommentPositive30Days(1);
     $firm->setCommentNeutral30Days(1);
     $firm->setCommentNegative30Days(2);
     $firm->setCommentPositiveAllDays(2);
     $firm->setCommentNeutralAllDays(1);
     $firm->setCommentNegativeAllDays(2);
     $firm->setCommentDate($dateTime = new \DateTime('2016-03-17 15:51:55'));
     $firm->setIpAdded('127.0.0.1');
     $firm->setDateAdded($dateTime);
     $firm->setIpUpdated('127.0.0.1');
     $firm->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firm);
     $em->flush();
     $firmCategory = new FirmCategory();
     $firmCategory->setFirm($firm);
     $firmCategory->setCategory($serviceCategory);
     $firmCategory->setActive(1);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firmCategory);
     $em->flush();
     $firmCategory = new FirmCategory();
     $firmCategory->setFirm($firm);
     $firmCategory->setCategory($scienceCategory);
     $firmCategory->setActive(1);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firmCategory);
     $em->flush();
     $firmCategory = new FirmCategory();
     $firmCategory->setFirm($firm);
     $firmCategory->setCategory($privateLessonCategory);
     $firmCategory->setActive(1);
     $em = $this->getDoctrine()->getManager();
     $em->persist($firmCategory);
     $em->flush();
     $picture = new Picture();
     $picture->setFirm($firm);
     $picture->setActive(1);
     $picture->setName('3D Budownictwo');
     $picture->setFile('1.jpg');
     $picture->setWidth(1024);
     $picture->setHeight(600);
     $picture->setFileMini('1-mini.jpg');
     $picture->setWidthMini(120);
     $picture->setHeightMini(120);
     $picture->setIpAdded('127.0.0.1');
     $picture->setDateAdded(new \DateTime('2016-03-30 15:36:43'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($picture);
     $em->flush();
     $picture = new Picture();
     $picture->setFirm($firm);
     $picture->setActive(1);
     $picture->setName('Twój Dom');
     $picture->setFile('2.jpg');
     $picture->setWidth(1024);
     $picture->setHeight(600);
     $picture->setFileMini('2-mini.jpg');
     $picture->setWidthMini(120);
     $picture->setHeightMini(120);
     $picture->setIpAdded('127.0.0.1');
     $picture->setDateAdded(new \DateTime('2016-03-30 15:37:43'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($picture);
     $em->flush();
     $picture = new Picture();
     $picture->setFirm($firm);
     $picture->setActive(1);
     $picture->setName('Piękny Ogród');
     $picture->setFile('3.jpg');
     $picture->setWidth(1024);
     $picture->setHeight(600);
     $picture->setFileMini('3-mini.jpg');
     $picture->setWidthMini(120);
     $picture->setHeightMini(120);
     $picture->setIpAdded('127.0.0.1');
     $picture->setDateAdded(new \DateTime('2016-03-30 15:38:43'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($picture);
     $em->flush();
     $picture = new Picture();
     $picture->setFirm($firm);
     $picture->setActive(1);
     $picture->setName('ABC Motoryzacja');
     $picture->setFile('4.jpg');
     $picture->setWidth(1024);
     $picture->setHeight(600);
     $picture->setFileMini('4-mini.jpg');
     $picture->setWidthMini(120);
     $picture->setHeightMini(120);
     $picture->setIpAdded('127.0.0.1');
     $picture->setDateAdded(new \DateTime('2016-03-30 15:46:43'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($picture);
     $em->flush();
     $picture = new Picture();
     $picture->setFirm($firm);
     $picture->setActive(1);
     $picture->setName('Archeton TZ');
     $picture->setFile('5.jpg');
     $picture->setWidth(1024);
     $picture->setHeight(600);
     $picture->setFileMini('5-mini.jpg');
     $picture->setWidthMini(120);
     $picture->setHeightMini(120);
     $picture->setIpAdded('127.0.0.1');
     $picture->setDateAdded(new \DateTime('2016-03-30 15:46:45'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($picture);
     $em->flush();
     $orderType1 = new OrderType();
     $orderType1->setActive(1);
     $orderType1->setName('Niezatwierdzone');
     $em = $this->getDoctrine()->getManager();
     $em->persist($orderType1);
     $em->flush();
     $orderType2 = new OrderType();
     $orderType2->setActive(1);
     $orderType2->setName('Zatwierdzone');
     $em = $this->getDoctrine()->getManager();
     $em->persist($orderType2);
     $em->flush();
     $orderType3 = new OrderType();
     $orderType3->setActive(1);
     $orderType3->setName('Odrzucone');
     $em = $this->getDoctrine()->getManager();
     $em->persist($orderType3);
     $em->flush();
     $commentType1 = new CommentType();
     $commentType1->setActive(1);
     $commentType1->setName('Pozytywny');
     $em = $this->getDoctrine()->getManager();
     $em->persist($commentType1);
     $em->flush();
     $commentType2 = new CommentType();
     $commentType2->setActive(1);
     $commentType2->setName('Neutralny');
     $em = $this->getDoctrine()->getManager();
     $em->persist($commentType2);
     $em->flush();
     $commentType3 = new CommentType();
     $commentType3->setActive(1);
     $commentType3->setName('Negatywny');
     $em = $this->getDoctrine()->getManager();
     $em->persist($commentType3);
     $em->flush();
     $markType1 = new MarkType();
     $markType1->setActive(1);
     $markType1->setName('Dokładność');
     $em = $this->getDoctrine()->getManager();
     $em->persist($markType1);
     $em->flush();
     $markType2 = new MarkType();
     $markType2->setActive(1);
     $markType2->setName('Kontakt');
     $em = $this->getDoctrine()->getManager();
     $em->persist($markType2);
     $em->flush();
     $markType3 = new MarkType();
     $markType3->setActive(1);
     $markType3->setName('Czas');
     $em = $this->getDoctrine()->getManager();
     $em->persist($markType3);
     $em->flush();
     $markType4 = new MarkType();
     $markType4->setActive(1);
     $markType4->setName('Cena');
     $em = $this->getDoctrine()->getManager();
     $em->persist($markType4);
     $em->flush();
     $order1 = new Order();
     $order1->setUser($user);
     $order1->setFirm($firm);
     $order1->setOrderType($orderType2);
     $order1->setActive(1);
     $order1->setRecommendation(0);
     $order1->setName('Nazwa zlecenia 1');
     $order1->setText('Opis zlecenia 1');
     $order1->setIpAdded('127.0.0.1');
     $order1->setDateAdded($dateTime = new \DateTime('2016-03-30 16:30:13'));
     $order1->setIpUpdated('127.0.0.1');
     $order1->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order1);
     $em->flush();
     $order2 = new Order();
     $order2->setUser($user);
     $order2->setFirm($firm);
     $order2->setOrderType($orderType2);
     $order2->setActive(1);
     $order2->setRecommendation(0);
     $order2->setName('Nazwa zlecenia 2');
     $order2->setText('Opis zlecenia 2');
     $order2->setIpAdded('127.0.0.1');
     $order2->setDateAdded($dateTime = new \DateTime('2016-03-30 16:31:13'));
     $order2->setIpUpdated('127.0.0.1');
     $order2->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order2);
     $em->flush();
     $order3 = new Order();
     $order3->setUser($user);
     $order3->setFirm($firm);
     $order3->setOrderType($orderType2);
     $order3->setActive(1);
     $order3->setRecommendation(0);
     $order3->setName('Nazwa zlecenia 3');
     $order3->setText('Opis zlecenia 3');
     $order3->setIpAdded('127.0.0.1');
     $order3->setDateAdded($dateTime = new \DateTime('2016-03-30 16:32:13'));
     $order3->setIpUpdated('127.0.0.1');
     $order3->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order3);
     $em->flush();
     $order4 = new Order();
     $order4->setUser($user);
     $order4->setFirm($firm);
     $order4->setOrderType($orderType2);
     $order4->setActive(1);
     $order4->setRecommendation(0);
     $order4->setName('Nazwa zlecenia 4');
     $order4->setText('Opis zlecenia 4');
     $order4->setIpAdded('127.0.0.1');
     $order4->setDateAdded($dateTime = new \DateTime('2016-03-30 16:33:13'));
     $order4->setIpUpdated('127.0.0.1');
     $order4->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order4);
     $em->flush();
     $order5 = new Order();
     $order5->setUser($user);
     $order5->setFirm($firm);
     $order5->setOrderType($orderType2);
     $order5->setActive(1);
     $order5->setRecommendation(0);
     $order5->setName('Nazwa zlecenia 5');
     $order5->setText('Opis zlecenia 5');
     $order5->setIpAdded('127.0.0.1');
     $order5->setDateAdded($dateTime = new \DateTime('2016-03-30 16:34:13'));
     $order5->setIpUpdated('127.0.0.1');
     $order5->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order5);
     $em->flush();
     $order6 = new Order();
     $order6->setUser($user);
     $order6->setFirm($firm);
     $order6->setOrderType($orderType1);
     $order6->setActive(1);
     $order6->setRecommendation(0);
     $order6->setName('Nazwa zlecenia 6');
     $order6->setText('Opis zlecenia 6');
     $order6->setIpAdded('127.0.0.1');
     $order6->setDateAdded($dateTime = new \DateTime('2016-03-30 16:35:13'));
     $order6->setIpUpdated('127.0.0.1');
     $order6->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order6);
     $em->flush();
     $order7 = new Order();
     $order7->setUser($user);
     $order7->setFirm($firm);
     $order7->setOrderType($orderType3);
     $order7->setActive(1);
     $order7->setRecommendation(0);
     $order7->setName('Nazwa zlecenia 7');
     $order7->setText('Opis zlecenia 7');
     $order7->setIpAdded('127.0.0.1');
     $order7->setDateAdded($dateTime = new \DateTime('2016-03-30 16:36:13'));
     $order7->setIpUpdated('127.0.0.1');
     $order7->setDateUpdated($dateTime);
     $em = $this->getDoctrine()->getManager();
     $em->persist($order7);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order1);
     $comment->setCommentType($commentType1);
     $comment->setActive(1);
     $comment->setUserComment(1);
     $comment->setText('Pierwszy komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:38:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order2);
     $comment->setCommentType($commentType2);
     $comment->setActive(1);
     $comment->setUserComment(1);
     $comment->setText('Drugi komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:39:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order3);
     $comment->setCommentType($commentType3);
     $comment->setActive(1);
     $comment->setUserComment(1);
     $comment->setText('Trzeci komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:40:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order4);
     $comment->setCommentType($commentType1);
     $comment->setActive(1);
     $comment->setUserComment(1);
     $comment->setText('Czwarty komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:41:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order5);
     $comment->setCommentType($commentType2);
     $comment->setActive(1);
     $comment->setUserComment(1);
     $comment->setText('Piąty komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:42:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order1);
     $comment->setCommentType($commentType3);
     $comment->setActive(1);
     $comment->setUserComment(0);
     $comment->setText('Szósty komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:43:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setFirm($firm);
     $comment->setOrder($order2);
     $comment->setCommentType($commentType1);
     $comment->setActive(1);
     $comment->setUserComment(0);
     $comment->setText('Siódmy komentarz...');
     $comment->setIpAdded('127.0.0.1');
     $comment->setDateAdded(new \DateTime('2016-03-30 17:44:00'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($comment);
     $em->flush();
     $mark = new Mark();
     $mark->setUser($user);
     $mark->setFirm($firm);
     $mark->setOrder($order1);
     $mark->setMarkType($markType1);
     $mark->setActive(1);
     $mark->setValue(5);
     $em = $this->getDoctrine()->getManager();
     $em->persist($mark);
     $em->flush();
     $mark = new Mark();
     $mark->setUser($user);
     $mark->setFirm($firm);
     $mark->setOrder($order2);
     $mark->setMarkType($markType2);
     $mark->setActive(1);
     $mark->setValue(4);
     $em = $this->getDoctrine()->getManager();
     $em->persist($mark);
     $em->flush();
     $mark = new Mark();
     $mark->setUser($user);
     $mark->setFirm($firm);
     $mark->setOrder($order3);
     $mark->setMarkType($markType3);
     $mark->setActive(1);
     $mark->setValue(3);
     $em = $this->getDoctrine()->getManager();
     $em->persist($mark);
     $em->flush();
     $mark = new Mark();
     $mark->setUser($user);
     $mark->setFirm($firm);
     $mark->setOrder($order4);
     $mark->setMarkType($markType4);
     $mark->setActive(1);
     $mark->setValue(2);
     $em = $this->getDoctrine()->getManager();
     $em->persist($mark);
     $em->flush();
     $mark = new Mark();
     $mark->setUser($user);
     $mark->setFirm($firm);
     $mark->setOrder($order5);
     $mark->setMarkType($markType4);
     $mark->setActive(1);
     $mark->setValue(1);
     $em = $this->getDoctrine()->getManager();
     $em->persist($mark);
     $em->flush();
     return new Response('Dane dodane');
 }
Example #6
0
 /**
  * @Route("/addComment/{item}" ,name="main_addComment")
  * @Security("has_role('ROLE_USER')")   
  */
 public function addCommentAction(Request $request, Item $item)
 {
     $text = $request->request->get('comment');
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     $comment = new Comment();
     $comment->setOwner($user);
     $comment->setItem($item);
     $comment->setText($text);
     $em->persist($comment);
     $em->flush();
     return $this->redirect($request->headers->get('referer'));
 }
 /**
  * {@inheritDoc}
  */
 public function setText($text)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setText', [$text]);
     return parent::setText($text);
 }
Example #8
0
 /**
  * @Route("id{id}/writeComment", name="commentFormAction")
  */
 public function commentAction($id, Request $request)
 {
     $comment = new Comment();
     $comment->setText($request->get('_comment'));
     $comment->setAuthor($this->getUser());
     $user = $this->getDoctrine()->getRepository('AppBundle:User')->find($id);
     $comment->setUser($user);
     $em = $this->getDoctrine()->getManager();
     $em->persist($this->getUser());
     $em->persist($user);
     $em->persist($comment);
     $em->flush();
     return $this->redirectToRoute('userPage', array('id' => $id));
 }