/**
  * @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 loadPosts(ObjectManager $manager)
 {
     $passwordEncoder = $this->container->get('security.password_encoder');
     $user = new User();
     $user->setUsername('vvasia');
     $user->setDisplayName('Vasia Vasin');
     $user->setEmail('*****@*****.**');
     $user->setUuid('uuid');
     $encodedPassword = $passwordEncoder->encodePassword($user, 'password');
     $user->setPassword($encodedPassword);
     $user->setRoles(['ROLE_USER']);
     $manager->persist($user);
     $manager->flush();
     /** @var User $author */
     $author = $manager->getRepository('AppBundle:User')->findOneBy(['email' => '*****@*****.**']);
     foreach (range(1, 10) as $i) {
         $post = new Post();
         $post->setTitle($this->getRandomPostTitle() . ' ' . uniqid())->setSummary($this->getRandomPostSummary())->setSlug($this->container->get('slugger')->slugify($post->getTitle()))->setContent($this->getPostContent())->setAuthor($author)->setPublishedAt(new \DateTime('now - ' . $i . 'days'))->setState($this->getRandomState())->setCategory($category);
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setUser($user)->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'))->setContent($this->getRandomCommentContent())->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         if (rand(0, 1)) {
             $vote = new Vote();
             $vote->setAuthorEmail(rand(0, 1) ? '*****@*****.**' : '*****@*****.**');
             $vote->setPost($post);
             $vote->setVote(rand(0, 1));
         }
         $manager->persist($post);
         $category->addPost($post);
     }
     $manager->flush();
 }
Example #3
0
 /**
  * @param int    $ideaId
  * @param string $content
  * @param bool   $isPrivate
  *
  * @return Comment
  * @throws \Exception
  */
 public function comment($ideaId, $content, $isPrivate)
 {
     $idea = $this->getIdea($ideaId);
     if ($idea instanceof Idea === false) {
         throw new \Exception("Unknown Idea[id={$ideaId}] aka 'I have no idea!'");
     }
     $user = $this->getAuthenticatedUser();
     $this->ensureAuthenticated($user);
     $comment = new Comment();
     $comment->setIdea($idea);
     $comment->setContent($content);
     $comment->setUser($user);
     $comment->setPrivate($isPrivate);
     $comment->setCreatedAt(new \DateTime());
     $this->entityManager->persist($comment);
     $this->entityManager->flush($comment);
     return $comment;
 }
 /**
  * @param Request $request
  * @param $slug
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @Route("/show/{slug}", name="add_comment")
  * @Method("POST")
  * @Template("AppBundle:Blog:article.html.twig")
  */
 public function addCommentAction(Request $request, $slug)
 {
     if (!$this->get('security.authorization_checker')->isGranted('ROLE_USER')) {
         throw $this->createAccessDeniedException();
     }
     $user = $this->getUser();
     $repository = $this->getDoctrine()->getRepository('AppBundle:Article');
     $article = $repository->findArticleBySlug($slug);
     $comment = new Comment();
     $comment->setUser($user);
     $comment->setArticle($article[0]);
     $form = $this->createForm(CommentType::class, $comment, ['action' => $this->generateUrl('add_comment', ['slug' => $slug]), 'method' => 'POST'])->add('save', SubmitType::class, ['label' => 'Add comment']);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($comment);
         $em->flush();
         return $this->redirect($this->generateUrl('show_article', ['slug' => $comment->getArticle()->getSlug()]));
     }
     return ['article' => $article, 'form' => $form->createView()];
 }
 public function addComment(Request $request, $slug, $id = null)
 {
     $em = $this->doctrine->getManager();
     $article = $em->getRepository("AppBundle:Article")->findOneBySlug($slug);
     if ($id != null) {
         $comment = $em->getRepository('AppBundle:Comment')->find($id);
     } else {
         $comment = new Comment();
         $comment->setArticle($article);
         $user = $this->tokenStorage->getToken()->getUser();
         $comment->setUser($user);
     }
     $form = $this->formFactory->create(CommentType::class, $comment, ['em' => $em, 'action' => $this->router->generate('commentForm', ['slug' => $slug, 'id' => $id]), 'method' => Request::METHOD_POST]);
     $form->add('save', SubmitType::class, array('label' => 'Submit Comment', 'attr' => array('class' => "btn btn-primary")));
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em->persist($comment);
             $em->flush();
             return new RedirectResponse($this->router->generate('success'));
         }
     }
     return ['form' => $form->createView()];
 }
Example #6
0
 public function getFrontShowElements(Request $request, $slug)
 {
     $em = $this->doctrine->getManager();
     $post = $em->getRepository('AppBundle:Post')->findBySlug($slug);
     $user = $this->getUser();
     if ($post[0] === null) {
         throw new NotFoundHttpException('Post not found');
     }
     $comment = new Comment();
     $comment->setPost($post[0]);
     $comment->setUser($user);
     $form = $this->formFactory->create(CommentType::class, $comment, ['method' => Request::METHOD_POST]);
     $form->add('save', SubmitType::class, array('label' => 'Submit Comment', 'attr' => array('class' => "btn btn-primary")));
     if ($request->getMethod() == 'POST' && $user) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $em->persist($comment);
             $em->flush();
             $url = $this->router->generate('show_post', ['slug' => $slug]);
             return new RedirectResponse($url, 301);
         }
     }
     return ['post' => $post, 'formComment' => $form->createView()];
 }
 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 #8
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 #9
0
 public function load(ObjectManager $manager)
 {
     $comment = new Comment();
     $comment->setUser('symfony');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('David');
     $comment->setComment('Пишіть і надалі');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Круто');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Не погано');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Stanley');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gabriel');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Mile');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-4')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gary');
     $comment->setComment('Чудова стаття');
     $comment->setBlog($manager->merge($this->getReference('blog-4')));
     $manager->persist($comment);
     $manager->flush();
 }
 public function load(ObjectManager $manager)
 {
     $comment = new Comment();
     $comment->setUser('symfony');
     $comment->setComment('To make a long story short. You can\'t go wrong by choosing Symfony!');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('David');
     $comment->setComment('To make a long story short. Make sure that you make the right selection!');
     $comment->setBlog($manager->merge($this->getReference('blog-1')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Donec dui enim, facilisis id sollicitudin sed, ullamcorper id lacus. Mauris eros felis, tincidunt elementum iaculis eu, iaculis sit amet sapien.');
     $comment->setBlog($manager->merge($this->getReference('blog-2')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Etiam eget diam pretium, auctor neque sit amet, pulvinar nibh?');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 06:15:20'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Name your stakes.');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 06:18:35'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('If I win, you give me ice cream.');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 06:22:53'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Ice Cream?');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 06:25:15'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Yes! Chocolate, with sprinkles, and whip cream...');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 06:46:08'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('And if I win?');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 10:22:46'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('I still get ice cream!');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-23 11:08:08'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Dade');
     $comment->setComment('Everyone wins!');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-24 18:56:01'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Kate');
     $comment->setComment('Deal!');
     $comment->setBlog($manager->merge($this->getReference('blog-3')));
     $comment->setCreated(new \DateTime('2011-07-25 22:28:42'));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Stanley');
     $comment->setComment('It\'s not gonna end like this.');
     $comment->setBlog($manager->merge($this->getReference('blog-4')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gabriel');
     $comment->setComment('Oh, come on, Stan. Not everything ends the way you think it should. Besides, audiences love happy endings.');
     $comment->setBlog($manager->merge($this->getReference('blog-4')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Mile');
     $comment->setComment('Doesn\'t Bill Gates have something like that?');
     $comment->setBlog($manager->merge($this->getReference('blog-5')));
     $manager->persist($comment);
     $comment = new Comment();
     $comment->setUser('Gary');
     $comment->setComment('Bill Who?');
     $comment->setBlog($manager->merge($this->getReference('blog-5')));
     $manager->persist($comment);
     $manager->flush();
 }
Example #11
0
 /**
  * Add comment
  *
  * @param \AppBundle\Entity\Comment $comment
  * @return Comment
  */
 public function addComment(\AppBundle\Entity\Comment $comment)
 {
     $this->comments[] = $comment;
     $comment->setUser($this);
     return $this;
 }
Example #12
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));
 }