/**
  * @Route("/content/{id}/new", name="_newContent")
  * @Method({"GET", "POST"})
  * @Template()
  * @param Request $request
  * @param Pages $page
  * @return array
  */
 public function newAction(Request $request, Pages $page)
 {
     $image = new Images();
     $form = $this->createForm(ImagesType::class, $image);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         // $file stores the uploaded jpg file
         /** @var File\UploadedFile $file */
         $file = $image->getImageName();
         var_dump($file);
         // Generate a unique name for the file before saving it
         $fileName = md5(uniqid()) . '.' . $file->guessExtension();
         // Move the file to the directory where images are stored
         $file->move($this->getParameter('images_directory'), $fileName);
         $image->setImageName($fileName);
         //Save Image to DB
         $em = $this->getDoctrine()->getManager();
         $em->persist($image);
         //Save Content to DB
         $content = new Content();
         $content->setImagesid($image);
         $content->setPagesid($page);
         $content->setOrdernumber(1);
         $em->persist($content);
         $em->flush();
         return $this->redirectToRoute('_indexContent', ['id' => $page->getId()]);
     }
     return ['form' => $form->createView(), 'pagesId' => $page->getId()];
 }
 public function onPostSubmit(FormEvent $event)
 {
     $content = $event->getData();
     if (!$content->getParentMultilangue()) {
         $content->setParentMultilangue($this->parentContent);
         $content->setCategory($this->selectCategoryParent($this->parentContent->getCategory(), $content->getLocale()));
     }
 }
Ejemplo n.º 3
0
 private function createObject(ObjectManager $manager, $title, $summary, $content)
 {
     $locales = $this->container->get('locales');
     $post = new Content($locales->getLocaleActive());
     $post->setTitle($title);
     $post->setSummary($summary);
     $post->setContent($content);
     $post->setType('post');
     $post->setStatus(true);
     $post->setCategory($this->getReference('category'));
     $manager->persist($post);
     foreach ($locales->getLocales() as $locale) {
         if (!$locale['active']) {
             $translationPost = new Content($locale['code']);
             $translationPost->setTitle($locale['code'] . ' ' . $title);
             $translationPost->setSummary($locale['code'] . ' ' . $summary);
             $translationPost->setContent($locale['code'] . ' ' . $content);
             $translationPost->setType('post');
             $translationPost->setStatus(true);
             $translationPost->setCategory($this->getReference('translationcategory-' . $locale['code']));
             $translationPost->setParentMultilangue($post);
             $manager->persist($translationPost);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @Route("/admin/table/{kind}/add", name="add_content")
  */
 public function addContentAction($kind, Request $request)
 {
     $content = new Content();
     $content->setKind($kind);
     $form = $this->createFormBuilder($content)->add('name', TextType::class, array('label' => 'Nazwa'))->add('description', TextareaType::class, array('label' => 'Opis'))->add('update', SubmitType::class, array('label' => 'Dodaj'))->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted()) {
         $content->setKind($kind);
         $em = $this->getDoctrine()->getManager();
         $em->persist($content);
         $em->flush();
         return $this->redirect($this->generateUrl('admin') . '#' . $kind);
     }
     return $this->render(':admin:row.html.twig', array('form' => $form->createView(), 'kind' => $kind));
 }
Ejemplo n.º 5
0
 public function load(ObjectManager $manager)
 {
     $locales = $this->container->get('locales');
     $page = new Content($locales->getLocaleActive());
     $page->setTitle('What is a Jedi?');
     $page->setSummary('A Jedi was a Force-sensitive individual, most often a member of the Jedi Order, who studied, served, and used the mystical energies of the Force; usually, the light side of the Force');
     $page->setContent('The weapon of a Jedi was the lightsaber, a blade made of pure energy. Jedi fought for peace and justice in the Galactic Republic, usually against their mortal enemy: the Sith, who studied the dark side of the Force. The Jedi were all but destroyed by the Sith during and after the execution of Order 66, leaving very few Jedi survivors until there was only one known living Jedi, Luke Skywalker, at the end of the Galactic Civil War.');
     $page->setType('page');
     $page->setStatus(true);
     $manager->persist($page);
     foreach ($locales->getLocales() as $locale) {
         if (!$locale['active']) {
             $translationPage = new Content($locale['code']);
             $translationPage->setTitle($locale['code'] . ' What is a Jedy?');
             $translationPage->setSummary($locale['code'] . ' A Jedi was a Force-sensitive individual, most often a member of the Jedi Order, who studied, served, and used the mystical energies of the Force; usually, the light side of the Force');
             $translationPage->setContent($locale['code'] . ' The weapon of a Jedi was the lightsaber, a blade made of pure energy. Jedi fought for peace and justice in the Galactic Republic, usually against their mortal enemy: the Sith, who studied the dark side of the Force. The Jedi were all but destroyed by the Sith during and after the execution of Order 66, leaving very few Jedi survivors until there was only one known living Jedi, Luke Skywalker, at the end of the Galactic Civil War.');
             $translationPage->setType('page');
             $translationPage->setStatus(true);
             $translationPage->setParentMultilangue($page);
             $manager->persist($translationPage);
         }
     }
     $manager->flush();
 }
 private function getTranslations(Content $content)
 {
     $contents = [];
     if ($content->getParentMultilangue()) {
         $contents[] = ['locale' => $content->getParentMultilangue()->getLocale(), 'language' => $this->locales->getLanguage($content->getParentMultilangue()->getLocale()), 'slug' => $content->getParentMultilangue()->getSlug(), 'title' => $content->getParentMultilangue()->getTitle(), 'slugcategory' => $content->getType() == 'post' ? $content->getParentMultilangue()->getCategory()->getSlug() : null, 'type' => $content->getType()];
         foreach ($content->getParentMultilangue()->getChildrenMultilangue() as $item) {
             if ($item->getLocale() != $content->getLocale() && $item->getStatus()) {
                 $contents[] = ['locale' => $item->getLocale(), 'language' => $this->locales->getLanguage($item->getLocale()), 'slug' => $item->getSlug(), 'title' => $item->getTitle(), 'slugcategory' => $content->getType() == 'post' ? $item->getCategory()->getSlug() : null, 'type' => $item->getType()];
             }
         }
     }
     if ($content->getChildrenMultilangue()) {
         foreach ($content->getChildrenMultilangue() as $item) {
             if ($item->getStatus()) {
                 $contents[] = ['locale' => $item->getLocale(), 'language' => $this->locales->getLanguage($item->getLocale()), 'slug' => $item->getSlug(), 'title' => $item->getTitle(), 'slugcategory' => $content->getType() == 'post' ? $item->getCategory()->getSlug() : null, 'type' => $item->getType()];
             }
         }
     }
     return $contents;
 }
 /**
  * @param Content $content
  *
  * @return \Symfony\Component\Form\Form
  */
 private function formDelete(Content $content)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_content_delete', ['id' => $content->getId()]))->setMethod('DELETE')->getForm();
 }
Ejemplo n.º 8
0
 public function load(ObjectManager $manager)
 {
     $c1 = new Content();
     $c1->setName('Biuro 1');
     $c1->setKind('office');
     $c1->setDescription('Nowoczesne małe biuro 10m2');
     $c2 = new Content();
     $c2->setName('Biuro 2');
     $c2->setKind('office');
     $c2->setDescription('Idealne dla zespołu 30m2');
     $c3 = new Content();
     $c3->setName('Plac maszynowy');
     $c3->setKind('square');
     $c3->setDescription('Wielki plac na maszyny budowlane 1000m2');
     $c4 = new Content();
     $c4->setName('Magazyn na beczki');
     $c4->setKind('warehouse');
     $c4->setDescription('Magazyn o pojemności 1000m3');
     $c5 = new Content();
     $c5->setName('Hotel');
     $c5->setKind('other');
     $c5->setDescription('Hotel 4 gwiazdkowy koło lotniska');
     $c6 = new Content();
     $c6->setName('Imie pracownika');
     $c6->setKind('tel');
     $c6->setDescription('+XX XXX-XXX-XXX');
     $c7 = new Content();
     $c7->setName('nazwa_firmy');
     $c7->setKind('desc');
     $c7->setDescription('Fal-Bruk');
     $c8 = new Content();
     $c8->setName('opis_firmy');
     $c8->setKind('desc');
     $c8->setDescription('Miejsce na dłuższy tekst np 1 akapit - około 3-5 zdań.');
     $c9 = new Content();
     $c9->setName('place');
     $c9->setKind('desc');
     $c9->setDescription('Opis placy - 1 zdanie');
     $c10 = new Content();
     $c10->setName('biura');
     $c10->setKind('desc');
     $c10->setDescription('Opis biur - 1 zdanie');
     $c11 = new Content();
     $c11->setName('inne');
     $c11->setKind('desc');
     $c11->setDescription('Opis innych lokalizacji - 1 zdanie');
     $c12 = new Content();
     $c12->setName('garaze_warsztaty');
     $c12->setKind('desc');
     $c12->setDescription('Opis warsztatów - 1 zdanie');
     $c13 = new Content();
     $c13->setName('dane_firmy');
     $c13->setKind('desc');
     $c13->setDescription('2016 Spółka ... dane spółkie');
     $c14 = new Content();
     $c14->setName('adres');
     $c14->setKind('desc');
     $c14->setDescription('Miejsce na adres firmy');
     $c15 = new Content();
     $c15->setName('naglowek');
     $c15->setKind('desc');
     $c15->setDescription('Nagłówek na początku strony');
     $c16 = new Content();
     $c16->setName('tekst1');
     $c16->setKind('desc');
     $c16->setDescription('Wynajme bezpośredni! Nie jesteśmy agencją.');
     $c17 = new Content();
     $c17->setName('tekst1_podpis');
     $c17->setKind('desc');
     $c17->setDescription('#nie płacisz prowizji');
     $c18 = new Content();
     $c18->setName('tekst2');
     $c18->setKind('desc');
     $c18->setDescription('X lat doświadczenia!');
     $c19 = new Content();
     $c19->setName('tekst2_podpis');
     $c19->setKind('desc');
     $c19->setDescription('#czujesz się bezpiecznie');
     $c20 = new Content();
     $c20->setName('tekst3');
     $c20->setKind('desc');
     $c20->setDescription('Około Y klientów!');
     $c21 = new Content();
     $c21->setName('tekst3_podpis');
     $c21->setKind('desc');
     $c21->setDescription('#jesteś traktowany profesjolanie');
     $manager->persist($c1);
     $manager->persist($c2);
     $manager->persist($c3);
     $manager->persist($c4);
     $manager->persist($c5);
     $manager->persist($c6);
     $manager->persist($c7);
     $manager->persist($c8);
     $manager->persist($c9);
     $manager->persist($c10);
     $manager->persist($c11);
     $manager->persist($c12);
     $manager->persist($c13);
     $manager->persist($c14);
     $manager->persist($c15);
     $manager->persist($c16);
     $manager->persist($c17);
     $manager->persist($c18);
     $manager->persist($c19);
     $manager->persist($c20);
     $manager->persist($c21);
     $manager->flush();
 }