/** * @param ObjectManager $manager */ protected function loadCities(ObjectManager $manager) { $cities = ['Örebro', 'Stockholm', 'Göteborg']; foreach ($cities as $i => $cityName) { $city = new City(); $city->setName($cityName); $manager->persist($city); $this->addReference(sprintf('city-%s', $i), $city); } }
/** * Transforms an object to a string (id). * * @param City|null $city * @return string */ public function transform($city) { if (null === $city) { return ''; } $title = $city->getTitle(); if ($country = $city->getCountry()) { $title .= ', ' . $country->getTitle(); } return $title; }
public function load(ObjectManager $manager) { $city = new City(); $city->setName('Kraków'); $manager->persist($city); $city = new City(); $city->setName('Warszawa'); $manager->persist($city); $city = new City(); $city->setName('Gdańsk'); $manager->persist($city); $city = new City(); $city->setName('Poznań'); $manager->persist($city); $city = new City(); $city->setName('Wrocław'); $manager->persist($city); $manager->flush(); }
/** * @param City $city * @return \Doctrine\ORM\Query */ public function findForList(City $city) { $qb = $this->createQueryBuilder('event'); return $qb->innerJoin('event.lectures', 'lecture')->andWhere($qb->expr()->eq('event.city', $city->getId()))->orderBy('event.date', 'DESC')->getQuery(); }
/** * Creates a form to delete a City entity. * * @param City $city The City entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(City $city) { return $this->createFormBuilder()->setAction($this->generateUrl('city_delete', array('id' => $city->getId())))->setMethod('DELETE')->getForm(); }
/** * @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'); }
public function parserGellary3Action($hot = false) { // $this->filePath = $this->filePath.'G2.XLSX'; $em = $this->em; $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Gallery roller'); if ($company == null) { $company = new Company(); $company->setTitle('Gallery roller'); $em->persist($company); $em->flush($company); $em->refresh($company); } $phpExcelObject = $this->container->get('phpexcel')->createPHPExcelObject($this->filePath); $num = 2; while (true) { if ($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue() == '') { break; } $banner = new Banner(); $banner->setCompany($company); $banner->setAdrs($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue()); $banner->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue()); $banner->setBody($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue()); $banner->setSide($this->getSide($phpExcelObject->setActiveSheetIndex(0)->getCell('D' . $num)->getValue())); $city = $this->em->getRepository('AppBundle:City')->findOneByTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue()); if ($city == null) { $city = new City(); $city->setTitle($phpExcelObject->setActiveSheetIndex(0)->getCell('A' . $num)->getValue()); $em->persist($city); $em->flush($city); $em->refresh($city); } $banner->setCity($city); $banner->setGid($phpExcelObject->setActiveSheetIndex(0)->getCell('N' . $num)->getValue()); $banner->setGrp(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('L' . $num)->getValue())); $banner->setOts(str_replace(',', '.', $phpExcelObject->setActiveSheetIndex(0)->getCell('M' . $num)->getValue())); $banner->setPrice(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('J' . $num)->getValue())); $banner->setPrice2(str_replace(array(',', ''), array('.', ''), $phpExcelObject->setActiveSheetIndex(0)->getCell('I' . $num)->getValue())); $banner->setPriceDeploy(0); $banner->setTaxType('НДС (18%)'); $banner->setFormat('small'); $banner->setType($phpExcelObject->setActiveSheetIndex(0)->getCell('B' . $num)->getValue()); $banner->setArea($phpExcelObject->setActiveSheetIndex(0)->getCell('W' . $num)->getValue()); $banner->setLight($phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'Да' || $phpExcelObject->setActiveSheetIndex(0)->getCell('C' . $num)->getValue() == 'да' ? 1 : 0); $banner->setImg($this->getImage($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl())); $banner->setLink($phpExcelObject->setActiveSheetIndex(0)->getCell('G' . $num)->getHyperlink()->getUrl()); if ($hot) { $banner->setHot(true); } else { $banner->setHot(false); } $url = 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($phpExcelObject->setActiveSheetIndex(0)->getCell('E' . $num)->getValue()); $content = file_get_contents($url); $XmlObj = simplexml_load_string($content); if (isset($XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)) { $pos['x'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[1]; $pos['y'] = explode(' ', $XmlObj->GeoObjectCollection->featureMember->GeoObject->Point->pos)[0]; } else { $pos['x'] = 0; $pos['y'] = 0; } $banner->setLongitude($pos['y']); $banner->setLatitude($pos['x']); $banner = $this->setBanner($banner); $month = array('2015-06-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('O' . $num)->getFill()->getStartColor()->getRGB()), '2015-07-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('P' . $num)->getFill()->getStartColor()->getRGB()), '2015-08-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('Q' . $num)->getFill()->getStartColor()->getRGB()), '2015-09-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('R' . $num)->getFill()->getStartColor()->getRGB()), '2015-10-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('S' . $num)->getFill()->getStartColor()->getRGB()), '2015-11-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('T' . $num)->getFill()->getStartColor()->getRGB()), '2015-12-01' => $this->getStatus($phpExcelObject->setActiveSheetIndex(0)->getStyle('U' . $num)->getFill()->getStartColor()->getRGB())); $this->refreshStatus($banner, $month, array('date' => '2015-06-01', 'sale' => $hot)); $num++; if ($num % 50 == 0) { sleep(rand(1, 5)); } } return true; }
/** * @Route("/parserRus/{type}", name="parserRus") */ public function parserRusAction($type) { set_time_limit(0); ini_set("memory_limit", "-1"); // if ($type == 1){ // $filename = '3x6/'.$filename.'.json'; // }elseif($type == 2){ // $filename = 'big/'.$filename; // } if ($type == 1) { $folder = '3x6'; } elseif ($type == 2) { $folder = 'big'; } $em = $this->getDoctrine()->getManager(); $company = $em->getRepository('AppBundle:Company')->findOneByTitle('Russoutdoor'); if ($company == null) { $company = new Company(); $company->setTitle('Russoutdoor'); $em->persist($company); $em->flush($company); $em->refresh($company); } $files = scandir($this->get('kernel')->getRootDir() . '/../web/' . $folder); unset($files[1]); unset($files[0]); foreach ($files as $f) { $filename = $this->get('kernel')->getRootDir() . '/../web/' . $folder . '/' . $f; $file = file_get_contents($filename); $array = json_decode($file, true); $i = 0; foreach ($array['billboards'] as $val) { if (isset($val['longtitude']) && isset($val['latitude']) && isset($val['address'])) { $i++; $banner = new Banner(); $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneByTitle($val['cityName']); if ($city == null) { $city = new City(); $city->setTitle($val['cityName']); $em->persist($city); $em->flush($city); $em->refresh($city); } $banner->setCity($city); $banner->setCompany($company); $banner->setAdrs($val['address']); $banner->setTitle($val['address']); $banner->setGid($val['gid']); $banner->setGrp($val['grp']); $banner->setOts($val['ots']); $banner->setPrice((isset($val['price']) ? $val['price'] : 0) * 0.82); $banner->setPrice2(isset($val['price']) ? $val['price'] : 0); $banner->setLight($val['light']); $banner->setSide($val['side']); $desc = (isset($val['top']) ? $val['top'] : '') . '<br />' . (isset($val['distance']) ? $val['distance'] : ''); $banner->setBody($desc); if ($type == 1) { $banner->setFormat('3x6'); } elseif ($type == 2) { $banner->setFormat('big'); } $banner->setLongitude($val['longtitude']); $banner->setLatitude($val['latitude']); $banner->setImg(str_replace('//', 'http://', $val['imageURL'])); $em->persist($banner); $em->flush(); } else { echo $val['address'] . '<br />'; echo '<br />'; print_r($val); echo '<br />'; echo '<br />'; } } } exit; }
public function editAction(Request $request) { $user = $this->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException('This user does not have access to this section.'); } /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */ $dispatcher = $this->get('event_dispatcher'); $event = new GetResponseUserEvent($user, $request); $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_INITIALIZE, $event); if (null !== $event->getResponse()) { return $event->getResponse(); } /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */ $formFactory = $this->get('fos_user.profile.form.factory'); $form = $formFactory->createForm(); $form->setData($user); $form->handleRequest($request); // if ( $request->getMethod('POST') ){ // dump($form); // exit; // } if ($request->getMethod() == 'POST') { $em = $this->getDoctrine()->getManager(); //city $cityTitle = $user->getCity(); $city = $this->getDoctrine()->getRepository('AppBundle:City')->findOneByTitle($cityTitle); if ($city === null) { $city = new City(); $city->setTitle($cityTitle); $city->setCountry($user->getCountry()); $em->persist($city); $em->flush($city); $em->refresh($city); } $user->setCity($city); //university $universityTitle = $user->getUniversity(); $university = $this->getDoctrine()->getRepository('AppBundle:University')->findOneByTitle($cityTitle); if ($university === null) { $university = new University(); $university->setTitle($universityTitle); $university->setCountry($user->getCountry()); $em->persist($university); $em->flush($university); $em->refresh($university); } $user->setUniversity($university); $user->setCertificate([]); /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ $userManager = $this->get('fos_user.user_manager'); $event = new FormEvent($form, $request); $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_SUCCESS, $event); $userManager->updateUser($user); if (null === ($response = $event->getResponse())) { $url = $this->generateUrl('fos_user_profile_show'); $response = new RedirectResponse($url); } $dispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response)); return $response; } return $this->render('FOSUserBundle:Profile:edit.html.twig', array('form' => $form->createView())); }
function parseCSVAction($from, $to) { die('nope'); $em = $this->getDoctrine()->getManager(); $file = __DIR__ . '/../../../_Njemacka.csv'; // $file = __DIR__ . '/../../../regions_subregions.csv'; // $file = __DIR__ . '/../../../regions_subregions_city2.csv'; $csv = array_map('str_getcsv', file($file)); // $csv = str_getcsv(file_get_contents(__DIR__ . '/../../../regions_subregions_city.csv')); $country = $em->getRepository('AppBundle:Country')->findOneByEn('Germany'); if ($country) { try { $i = 0; $count = 0; foreach ($csv as $c) { if ($c[0] != 'GRAD' && ($i >= $from && $i <= $to)) { $regionCSV = $c[1]; $region = $em->getRepository('AppBundle:Region')->findOneByEn($regionCSV); if (!$region) { $region = new Region(); $region->setCountry($country); $region->setEn($c[1]); // $region->setDe($c[2]); # Depends on country // $region->setIt($c[2]); $em->persist($region); $em->flush(); } $subregion = false; // $subregionCSV = $c[1]; // $subregion = $em->getRepository('AppBundle:Subregion')->findOneByEn($subregionCSV); // if (!$subregion) { // $subregion = new Subregion(); // $subregion->setRegion($region); // $subregion->setEn($c[1]); // $em->persist($subregion); // $em->flush(); // } $cityCSV = $c[0]; $city = $em->getRepository('AppBundle:City')->findOneByEn($cityCSV); if (!$city) { $city = new City(); $city->setRegion($region); $city->setEn($cityCSV); if ($subregion) { $city->setSubregion($subregion); } $em->persist($city); $em->flush(); } $count++; } $i++; } } catch (\Exception $e) { return new Response($e); } } return new Response($count); // echo'<pre>';print_r($csv);echo'</pre>'; }
/** * @Route("/city/create", name="city_create") */ public function createCityAction() { $region = $this->getDoctrine()->getRepository('AppBundle:Region')->findOneByName("Poltava area"); $city = new City(); $city->setName('Gadiach'); $city->setRegion($region); $em = $this->getDoctrine()->getManager(); $em->persist($region); $em->persist($city); $em->flush(); return new Response('Created city id ' . $city->getId()); }