Exemplo n.º 1
0
 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.JPG')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'portfolio', 'sonata.media.provider.image');
     }
     $pro = new Project();
     $pro->setTechnology($em->merge($this->getReference("Technology-web")));
     $pro->setName("Symfony2 Portfolio");
     $pro->setMedia($media);
     $pro->setDescription('aaa');
     $pro->setRawContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro->setContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro->setUrl("no");
     $pro->setDate(new \DateTime());
     $pro2 = new Project();
     $pro2->setTechnology($em->merge($this->getReference("Technology-asm")));
     $pro2->setName("Symfony2 Portfolio test");
     $pro2->setMedia($media);
     $pro2->setDescription('asfasfasf');
     $pro2->setRawContent("\nsdf\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro2->setContent("\nsdf\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
     $pro2->setUrl("no");
     $pro2->setDate(new \DateTime());
     $em->persist($pro2);
     $em->persist($pro);
     $em->flush();
 }
Exemplo n.º 2
0
 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.*')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     $medias = [];
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'gallery', 'sonata.media.provider.image');
         $medias[] = $media;
     }
     for ($i = 1; $i < 2; $i++) {
         $post = new Photo();
         $post->setCategory($em->merge($this->getReference("PhotoCategory-1")));
         $post->setTitle("testowe " . $i);
         $post->setImage($medias[0]);
         $post2 = new Photo();
         $post2->setCategory($em->merge($this->getReference("PhotoCategory-" . rand(1, 6))));
         $post2->setTitle("testowe " . $i);
         $post2->setImage($medias[1]);
         $em->persist($post2);
         $em->persist($post);
         $em->flush();
         $this->addReference('Photo-' . $i, $post);
         $this->addReference('Photo-' . ($i - 1), $post2);
     }
 }
Exemplo n.º 3
0
 public function preUpload(PreUploadEvent $event)
 {
     //echo "preUpload";die();
     /*$response = $event->getResponse();
       $msg = "test";
       $response->setSuccess(false);
       $response->setError($msg);*/
     $galleryId = $event->getRequest()->get('galleryId');
     $file = $event->getFile();
     $media = new Media();
     //$media->setName($file->getBasename());
     $media->setName($file->getClientOriginalName());
     $media->setBinaryContent($file);
     $media->setEnabled(true);
     $media->setContext('default');
     $media->setProviderName('sonata.media.provider.image');
     $this->em = $this->doctrine[0]->getEntityManager();
     $gallery = $this->em->getRepository('ApplicationSonataMediaBundle:Gallery')->find($galleryId);
     $galleryHasMedia = new GalleryHasMedia();
     $galleryHasMedia->setMedia($media);
     $galleryHasMedia->setEnabled(true);
     $gallery->addGalleryHasMedias($galleryHasMedia);
     $this->em->persist($galleryHasMedia);
     $this->em->persist($media);
     $this->em->flush();
     die;
 }
Exemplo n.º 4
0
 public function getMedia($name, $context = 'default')
 {
     $media = new Media();
     $media->setBinaryContent(__DIR__ . '/../data/' . $name);
     $media->setContext($context);
     $media->setProviderName('sonata.media.provider.image');
     $this->container->get('sonata.media.manager.media')->save($media, $andFlush = true);
     return $media;
 }
 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.*')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     $medias = [];
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'gallery', 'sonata.media.provider.image');
         $medias[] = $media;
     }
     $design = new PhotoCategory();
     $design->setName('Grafika');
     $design->setSlug(Inftech::slugify('Grafika'));
     $design->setImage($medias[0]);
     $design->setGallery($em->merge($this->getReference('Gallery-1')));
     $design2 = new PhotoCategory();
     $design2->setName('Grafika2');
     $design2->setSlug(Inftech::slugify('Grafika2'));
     $design2->setImage($medias[1]);
     $design2->setGallery($em->merge($this->getReference('Gallery-1')));
     $design3 = new PhotoCategory();
     $design3->setName('Grafika4');
     $design3->setSlug(Inftech::slugify('Grafika4'));
     $design3->setImage($medias[3]);
     $design3->setGallery($em->merge($this->getReference('Gallery-1')));
     $design4 = new PhotoCategory();
     $design4->setName('Grafika3');
     $design4->setSlug(Inftech::slugify('Grafika3'));
     $design4->setImage($medias[2]);
     $design4->setGallery($em->merge($this->getReference('Gallery-1')));
     $programming = new PhotoCategory();
     $programming->setName('Programowanie');
     $programming->setSlug(Inftech::slugify('Programowanie'));
     $programming->setImage($medias[4]);
     $programming->setGallery($em->merge($this->getReference('Gallery-2')));
     $linux = new PhotoCategory();
     $linux->setName('Linux');
     $linux->setSlug(Inftech::slugify('Linux'));
     $linux->setImage($medias[5]);
     $linux->setGallery($em->merge($this->getReference('Gallery-2')));
     $em->persist($design);
     $em->persist($programming);
     $em->persist($linux);
     $em->persist($design2);
     $em->persist($design3);
     $em->persist($design4);
     $em->flush();
     $this->addReference('PhotoCategory-1', $design);
     $this->addReference('PhotoCategory-4', $design2);
     $this->addReference('PhotoCategory-6', $design3);
     $this->addReference('PhotoCategory-5', $design4);
     $this->addReference('PhotoCategory-2', $programming);
     $this->addReference('PhotoCategory-3', $linux);
 }
Exemplo n.º 6
0
 public function generateMediaFromFile($file)
 {
     $media = new Media();
     $media->setBinaryContent(new File($file));
     $media->setContext('default');
     $media->setProviderName('sonata.media.provider.image');
     $media->setName($this->getFileName($file));
     $media->setEnabled(true);
     return $media;
 }
 /**
  * @param UploadedFile $uploadedFile
  * @param string $context
  * @return Image
  */
 private function saveImage(UploadedFile $uploadedFile, $context)
 {
     $media = new Media();
     $media->setBinaryContent($uploadedFile);
     $media->setContext($context);
     $media->setProviderName('sonata.media.provider.image');
     $this->mediaManager->save($media);
     $image = new Image();
     $image->setFile($media);
     $this->imageManager->save($image);
     return $image;
 }
Exemplo n.º 8
0
 /**
  * Creates a new Lots entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Lots();
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $user = $this->container->get('security.context')->getToken()->getUser();
         $entity->setUser($user);
         $uploadedFiles = $request->files->get('myfile');
         $numUploadedFiles = count($uploadedFiles);
         if ($numUploadedFiles > 0) {
             $tmp_gallery = new Gallery();
             $mediaManager = $this->container->get('sonata.media.manager.media');
             $uploadedFiles = $request->files->get('myfile');
             $tmp_gallery->setName($entity->getTitle());
             $tmp_gallery->setContext('default');
             $tmp_gallery->setDefaultFormat('default_small');
             $tmp_gallery->setEnabled(true);
             //            $em->persist($tmp_gallery);
             //            $em->refresh($tmp_gallery);
             for ($i = 0; $i < $numUploadedFiles; $i++) {
                 $tmp_media = new Media();
                 $tmp_galleryHasMedia = new GalleryHasMedia();
                 $tmp_media->setBinaryContent($uploadedFiles[$i]->getRealPath());
                 $tmp_media->setContext('default');
                 $tmp_media->setName($uploadedFiles[$i]->getClientOriginalName());
                 $mediaManager->save($tmp_media, 'default', 'sonata.media.provider.image');
                 $tmp_galleryHasMedia->setMedia($tmp_media);
                 $tmp_galleryHasMedia->setEnabled(true);
                 $tmp_galleryHasMedia->setGallery($tmp_gallery);
                 $em->persist($tmp_galleryHasMedia);
             }
             $em->persist($tmp_gallery);
             $em->flush();
             $em->refresh($tmp_gallery);
             $entity->setGallery($tmp_gallery);
         }
         $offer = new Offer();
         $em->persist($offer);
         $entity->setOffer($offer);
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('lots_show', array('id' => $entity->getId())));
     }
     return $this->render('AESlandsBundle:Lots:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }
 public function testExecuteCommand()
 {
     $kernel = $this->createKernel();
     $kernel->boot();
     $application = new Application($kernel);
     $application->add(new RemoveBrokenMediaObjectsCommand());
     $command = $application->find('app:remove-image');
     $commandTester = new CommandTester($command);
     $commandTester->execute([]);
     $this->assertContains("Deleted media without reference object was successful", $commandTester->getDisplay());
     $commandTester->execute([]);
     $this->assertNotContains("Remove media with", $commandTester->getDisplay());
     $media = new Media();
     $media->setBinaryContent(__DIR__ . '/../../DataFixtures/data/avatars/anna-bobrova.jpg');
     $media->setContext('employee');
     $media->setProviderName('sonata.media.provider.image');
     $this->getContainer()->get('sonata.media.manager.media')->save($media, $andFlush = true);
     $this->getEm()->persist($media);
     $this->getEm()->flush();
     $commandTester->execute([]);
     $this->assertContains("Removed media with id", $commandTester->getDisplay());
 }
Exemplo n.º 10
0
 /**
  * @Route("/media/upload/excerpt", name="ed_blog_admin_media_upload_excerpt")
  */
 public function uploadExcerptAction(Request $request)
 {
     $user = $this->getBlogUser();
     $mediaManager = $this->container->get('sonata.media.manager.media');
     $builder = $this->createFormBuilder();
     $form = $builder->add('excerptImage', 'file', array('required' => false))->getForm();
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         $attachment = $form['excerptImage']->getData();
         $media = new Media();
         $media->setBinaryContent($attachment);
         $media->setContext('default');
         $media->setProviderName('sonata.media.provider.image');
         $media->setName($attachment->getClientOriginalName());
         $mediaManager->save($media);
         return new JsonResponse(array('success' => 'true', 'id' => $media->getId(), 'href' => $this->generateUrl('ed_blog_admin_media_delete', array('id' => $media->getId())), 'media' => $this->renderView('EDBlogBundle:Media:image.html.twig', array('media' => $media))));
     }
     return new JsonResponse(array('success' => 'false'));
 }
 /**
  * {@inheritDoc}
  */
 public function setBinaryContent($binaryContent)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setBinaryContent', array($binaryContent));
     return parent::setBinaryContent($binaryContent);
 }
Exemplo n.º 12
0
 /**
  * @Route("/upload", name="ed_blog_admin_article_upload")
  */
 public function uploadAction(Request $request)
 {
     $user = $this->getBlogUser();
     $mediaManager = $this->container->get('sonata.media.manager.media');
     if (!$request->get('excerpt', false)) {
         $form = $this->createForm(new ArticlePhotoType());
     } else {
         $form = $this->createForm(new ArticleExcerptType());
     }
     if ($request->getMethod() == 'POST') {
         $form->handleRequest($request);
         $dispatcher = $this->get('event_dispatcher');
         $attachment = $form['media']->getData();
         //to support single file upload (multiple=false)
         if (!is_array($attachment)) {
             $attachment = array($attachment);
         }
         $mediaArray = new ArrayCollection();
         $errorArray = array();
         foreach ($attachment as $attached) {
             if (in_array($attached->getMimeType(), array('image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png', 'image/gif'))) {
                 try {
                     $media = new Media();
                     $media->setBinaryContent($attached);
                     $media->setContext('default');
                     $media->setProviderName('sonata.media.provider.image');
                     $media->setName($attached->getClientOriginalName());
                     $media->setEnabled(true);
                     $mediaManager->save($media);
                     $mediaArray->add($media);
                 } catch (\Exception $e) {
                     $errorArray[] = array("name" => $attached->getClientOriginalName(), "message" => $e->getMessage());
                 }
             } else {
                 $errorArray[] = array("name" => $attached->getClientOriginalName(), "message" => "The file is unsupported");
             }
         }
         $dispatcher->dispatch(EDBlogEvents::ED_BLOG_MEDIA_LIBRARY_MEDIA_UPLOADED, new MediaArrayEvent($mediaArray));
     }
     $paginator = $this->get('blog.paginator');
     $response = $this->getPaginated($paginator, array('errors' => $errorArray));
     return $response;
 }
Exemplo n.º 13
0
 public function load(ObjectManager $em)
 {
     $files = Finder::create()->name('*.JPG')->in(__DIR__ . '/../data/files');
     $manager = $this->container->get('sonata.media.manager.media');
     foreach ($files as $pos => $file) {
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $manager->save($media, 'blog', 'sonata.media.provider.image');
     }
     for ($i = 0; $i < 52; $i = $i + 3) {
         $post = new Post();
         $post->setCategory($em->merge($this->getReference("PostCategory-design")));
         $post->setCommentCount(0);
         $post->setTitle("o autorze" . $i);
         $post->setContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
         $post->setRawContent("\n\n          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cursus id felis. Sed lorem quam, vehicula in consequat\n          id, auctor eget odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ");
         $post->setUser($em->merge($this->getReference("User-aldor")));
         $post->setDescription("Krotki wstep. bardzo");
         $post->setDate(new \DateTime());
         $post->setModified(new \DateTime());
         $post->setPublicationDateStart(new \DateTime());
         $post->setStatus("public");
         $post->setCommentStatus("open");
         $post->setUrl($post->getCategorySlug() . $post->getDateSlug() . $post->getTitleSlug());
         $post->setMedia($media);
         $post2 = new Post();
         $post2->setCategory($em->merge($this->getReference("PostCategory-cubie")));
         $post2->setCommentCount(0);
         $post2->setTitle("Drugi Testowy tytuł dokumentu" . $i);
         $post2->setDescription("Krotki wstep. bardzo");
         $post2->setContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cur ");
         $post2->setRawContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cur ");
         $post2->setUser($em->merge($this->getReference("User-aldor")));
         $post2->setStatus("public");
         $post2->setCommentStatus("close");
         $post2->setDate(new \DateTime());
         $post2->setModified(new \DateTime());
         $post2->setPublicationDateStart(new \DateTime());
         $post2->setUrl($post2->getCategorySlug() . $post2->getDateSlug() . $post2->getTitleSlug());
         $post2->setMedia($media);
         $post3 = new Post();
         $post3->setCategory($em->merge($this->getReference("PostCategory-cubie")));
         $post3->setCommentCount(0);
         $post3->setTitle("trzeci gi Testowy tytuł dokumentu" . $i);
         $post3->setContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cur");
         $post3->setRawContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper varius urna,\n          in ultrices arcu auctor sed. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.\n          Etiam dolor tellus, posuere at tincidunt at, consequat et mi. Curabitur accumsan aliquet interdum. Nullam lacus velit, varius non dictum in,\n          interdum vel tortor. Maecenas eget quam lorem, vel aliquet tellus. Fusce vel diam diam, at vehicula lorem. Nunc consequat dolor vel ante\n          accumsan auctor. Aenean euismod, quam sit amet mattis tincidunt, odio massa iaculis lectus, in consectetur quam sapien in lorem. Suspendisse blandi\n          t feugiat ipsum vitae gravida. Maecenas et turpis odio. Vivamus nec velit ac purus vestibulum ullamcorper. Aliquam nisi tortor, viverra ut ullamcorper nec, cur");
         $post3->setDescription("Lorem ipsum jakis teskt ala asf ");
         $post3->setDescription("Lorem ipsum jakis teskt ala asf ");
         $post3->setUser($em->merge($this->getReference("User-aldor")));
         $post3->setUrl("slug");
         $post3->setStatus("public");
         $post3->setCommentStatus("close");
         $post3->setDate(new \DateTime());
         $post3->setModified(new \DateTime());
         $post3->setPublicationDateStart(new \DateTime());
         $post3->setMedia($media);
         $post3->setUrl($post3->getCategorySlug() . $post3->getDateSlug() . $post3->getTitleSlug());
         $em->persist($post2);
         $em->persist($post);
         $em->persist($post3);
         $em->flush();
         $this->addReference('Post-' . ($i - 2), $post);
         $this->addReference('Post-' . ($i - 1), $post2);
         $this->addReference('Post-' . $i, $post3);
     }
 }
Exemplo n.º 14
0
 protected function addPhotosToCategory($message)
 {
     $categoryName = $message->getValue('categoryName');
     $filePath = $message->getValue('filePath');
     $category = $this->enityManager->getRepository('AldorGalleryBundle:PhotoCategory')->findOneByName($categoryName);
     $zip = new ExtractZip($filePath);
     $files = $zip->extract();
     $counter = 0;
     $maxSequence = $this->enityManager->getRepository('AldorGalleryBundle:Photo')->getMaxSequenceByCategory($category->getId());
     foreach ($files as $pos => $file) {
         $title = explode('/', $pos);
         $fileName = $title[count($title) - 1];
         $fileName = str_replace('DSC_', '', $fileName);
         $title = $categoryName . '-' . explode('.', $fileName)[0];
         $photo = new Photo();
         $photo->setTitle($title);
         $media = new Media();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $media->setContext('gallery');
         $media->setName($categoryName . '-' . $fileName);
         $photo->setImage($media);
         $photo->addCategory($category);
         $photo->setSequence($maxSequence++);
         $this->enityManager->persist($photo);
     }
     $this->enityManager->flush();
     $zip->clean();
 }