當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Post::setAuthorEmail方法代碼示例

本文整理匯總了PHP中AppBundle\Entity\Post::setAuthorEmail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::setAuthorEmail方法的具體用法?PHP Post::setAuthorEmail怎麽用?PHP Post::setAuthorEmail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppBundle\Entity\Post的用法示例。


在下文中一共展示了Post::setAuthorEmail方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 0; $i < 50; $i++) {
         static $id = 1;
         $post = new Post();
         $post->setTitle($faker->sentence);
         $post->setAuthorEmail('user_admin@blog.com');
         $post->setImageName("images/post/foto{$id}.jpg");
         $post->setContent($faker->realText($maxNbChars = 5000, $indexSize = 2));
         $marks = array();
         for ($q = 0; $q < rand(1, 10); $q++) {
             $marks[] = rand(1, 5);
         }
         $post->setMarks($marks);
         $post->addMark(5);
         $manager->persist($post);
         $this->addReference("{$id}", $post);
         $id = $id + 1;
         $rand = rand(3, 7);
         for ($j = 0; $j < $rand; $j++) {
             $comment = new Comment();
             $comment->setAuthorEmail('user_user@blog.com');
             $comment->setCreatedBy('user_user');
             $comment->setContent($faker->realText($maxNbChars = 500, $indexSize = 2));
             $comment->setPost($post);
             $post->getComments()->add($comment);
             $manager->persist($comment);
             $manager->flush();
         }
     }
     $manager->flush();
 }
開發者ID:syrotchukandrew,項目名稱:blog,代碼行數:33,代碼來源:LoadPostData.php

示例2: createAction

 /**
  * @Route("/create", name="create_post")
  */
 public function createAction(Request $request)
 {
     // just setup a fresh $post object (remove the dummy data)
     $post = new Post();
     $post->setAuthorEmail('dipsetm12@hotmail.fr');
     $form = $this->createForm(new PostType(), $post);
     $finder = new Finder();
     $data = $finder->files()->in($_SERVER['DOCUMENT_ROOT'] . 'Benedictux/web/upload');
     //$data = $this->get('app.scanner')->scanDir($_SERVER['DOCUMENT_ROOT'].'Benedictux/web/uploads');
     //$data = $this->get('app.scanner')->scanDirectory($this->get('request')->getBasePath());
     //$scanned_directory = array_diff(scandir('./web'), array('..', '.'));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $slug = $this->get('app.slugger')->slugify($post->getTitle());
         $post->setSlug($slug);
         if (get_magic_quotes_gpc()) {
             $content = stripslashes($post->getContent());
             $content = $this->get('app.parser')->parserTexarea($content);
             $post->setContent($content);
         } else {
             $content = $this->get('app.parser')->parserTexarea($post->getContent());
             $post->setContent($content);
         }
         $em->persist($post);
         $em->flush();
         return $this->redirectToRoute('accueil');
     }
     return $this->render('app/postCreate.html.twig', array('form' => $form->createView(), 'data' => $data));
 }
開發者ID:Benedictux,項目名稱:Benedictux,代碼行數:33,代碼來源:PostController.php

示例3: newAction

 /**
  * Creates a new Post entity
  *
  * @Route("/new", name="super_admin_post_new")
  * @Method({"GET", "POST"})
  *
  */
 public function newAction(Request $request)
 {
     $post = new Post();
     $post->setAuthorEmail($this->getUser()->getEmail());
     // See http://symfony.com/doc/current/book/forms.html#submitting-forms-with-multiple-buttons
     $form = $this->createForm(new PostType(), $post)->add('saveAndCreateNew', 'submit');
     $form->handleRequest($request);
     // the isSubmitted() method is completely optional because the other
     // isValid() method already checks whether the form is submitted.
     // However, we explicitly add it to improve code readability.
     // See http://symfony.com/doc/current/best_practices/forms.html#handling-form-submits
     if ($form->isSubmitted() && $form->isValid()) {
         $post->setSlug($this->get('slugger')->slugify($post->getTitle()));
         $entityManager = $this->getDoctrine()->getManager();
         $entityManager->persist($post);
         $entityManager->flush();
         // Flash messages are used to notify the user about the result of the
         // actions. They are deleted automatically from the session as soon
         // as they are accessed.
         // See http://symfony.com/doc/current/book/controller.html#flash-messages
         /** SHOW INFO **/
         $this->addFlash('success', 'post.created_successfully');
         if ($form->get('saveAndCreateNew')->isClicked()) {
             // -- repair
             return $this->redirectToRoute('super_admin_post_new');
         }
         // -- repair
         return $this->redirectToRoute('super_admin_post_index');
     }
     // repair
     return $this->render('superadmin/blog/new.html.twig', array('post' => $post, 'form' => $form->createView()));
 }
開發者ID:quangtuanle,項目名稱:alano_project,代碼行數:39,代碼來源:BlogController.php

示例4: newAction

 /**
  * Creates a new Post entity.
  *
  * @Route("/new", name="admin_post_new")
  * @Method({"GET", "POST"})
  *
  * NOTE: the Method annotation is optional, but it's a recommended practice
  * to constraint the HTTP methods each controller responds to (by default
  * it responds to all methods).
  */
 public function newAction(Request $request)
 {
     $post = new Post();
     $post->setAuthorEmail($this->getUser()->getEmail());
     $form = $this->createForm(new PostType(), $post);
     $form->handleRequest($request);
     // the isSubmitted() method is completely optional because the other
     // isValid() method already checks whether the form is submitted.
     // However, we explicitly add it to improve code readability.
     // See http://symfony.com/doc/current/best_practices/forms.html#handling-form-submits
     if ($form->isSubmitted() && $form->isValid()) {
         $post->setSlug($this->get('slugger')->slugify($post->getTitle()));
         $entityManager = $this->getDoctrine()->getManager();
         $entityManager->persist($post);
         $entityManager->flush();
         //On envoie un mail de notification à tous les abonnés
         $notificationService = $this->get('notification_manager');
         $urlNouveauPost = $this->generateUrl('blog_post', array('slug' => $post->getSlug()));
         $notificationService->envoyerMailTousLesAbonnes(new Notification($post->getTitle(), $post->getSummary(), $urlNouveauPost));
         // Flash messages are used to notify the user about the result of the
         // actions. They are deleted automatically from the session as soon
         // as they are accessed.
         // See http://symfony.com/doc/current/book/controller.html#flash-messages
         $this->addFlash('success', 'post.created_successfully');
         return $this->redirectToRoute('admin_post_index');
     }
     return $this->render('admin/blog/new.html.twig', array('post' => $post, 'form' => $form->createView()));
 }
開發者ID:remi-picard,項目名稱:techlunch-symfony2,代碼行數:38,代碼來源:BlogController.php

示例5: loadPosts

 private function loadPosts(ObjectManager $manager)
 {
     foreach (range(1, 30) as $i) {
         $post = new Post();
         $post->setTitle('Sed ut perspiciatis unde');
         $post->setAlias('Sed ut perspiciatis unde');
         $post->setIntrotext('Sed ut perspicantium, tocto beatae vitae dicta sunt explicabo. ');
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setBody('Sed ut is iste uasi architecto beatae vitae dicta sunt explicabo. ');
         $post->setAuthorEmail('anna_admin@symfony.com');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         $post->setState(1);
         $post->setImages('test.jpg');
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('john_user@symfony.com');
             $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $comment->setContent('Sed ut perspiciatis undedasdadasd');
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
開發者ID:alegperea,項目名稱:CMS,代碼行數:26,代碼來源:LoadFixtures.php

示例6: loadPosts

 private function loadPosts(ObjectManager $manager)
 {
     $category = new Category();
     $category->setName('Improvements');
     foreach (range(1, 5) as $i) {
         $post = new Post();
         $post->setTitle($this->getRandomPostTitle());
         $post->setSummary($this->getRandomPostSummary());
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setContent($this->getPostContent());
         $post->setAuthorEmail('a.martynenko@levi9.com');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         $post->setState($this->getRandomState());
         $post->setCategory($category);
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('d.kiprushev@levi9.com');
             $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $comment->setContent($this->getRandomCommentContent());
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         if (rand(0, 1)) {
             $vote = new Vote();
             $vote->setAuthorEmail(rand(0, 1) ? 'a.martynenko@levi9.com' : 'd.kiprushev@levi9.com');
             $vote->setPost($post);
             $vote->setVote(rand(0, 1));
         }
         $manager->persist($post);
         $category->addPost($post);
     }
     $manager->flush();
 }
開發者ID:panayotovyura,項目名稱:levi9voter,代碼行數:34,代碼來源:LoadFixtures.php

示例7: newAction

 /**
  * Creates a new Post entity.
  *
  * @Route("/new", name="admin_post_new")
  *
  * @Method({"GET", "POST"})
  *
  * NOTE: the Method annotation is optional, but it's a recommended practice
  * to constraint the HTTP methods each controller responds to (by default
  * it responds to all methods).
  */
 public function newAction(Request $request)
 {
     $post = new Post();
     $post->setAuthorEmail($this->getUser()->getEmail());
     $form = $this->createForm(new PostType(), $post);
     $form->handleRequest($request);
     // the isSubmitted() method is completely optional because the other
     // isValid() method already checks whether the form is submitted.
     // However, we explicitly add it to improve code readability.
     // See http://symfony.com/doc/current/best_practices/forms.html#handling-form-submits
     if ($form->isSubmitted() && $form->isValid()) {
         $post->setSlug($this->get('slugger')->slugify($post->getTitle()));
         $em = $this->getDoctrine()->getManager();
         $em->persist($post);
         $em->flush();
         return $this->redirectToRoute('admin_post_index');
     }
     return $this->render('admin/blog/new.html.twig', array('post' => $post, 'form' => $form->createView()));
 }
開發者ID:blackfireio,項目名稱:blackfire-workshop,代碼行數:30,代碼來源:BlogController.php

示例8: newAction

 /**
  * Yeni Makale oluşturur
  *
  * @Route("/new", name="admin_post_new")
  * @Method({"GET", "POST"})
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function newAction(Request $request)
 {
     $post = new Post();
     $post->setAuthorEmail($this->getUser()->getEmail());
     $form = $this->createForm('AppBundle\\Form\\PostType', $post)->add('saveAndCreateNew', 'Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType');
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $post->setSlug($this->get('slugger')->slugify($post->getTitle()));
         $entityManager = $this->getDoctrine()->getManager();
         $entityManager->persist($post);
         $entityManager->flush();
         $this->addFlash('success', 'Makale başarıyla oluşturuldu');
         if ($form->get('saveAndCreateNew')->isClicked()) {
             return $this->redirectToRoute('admin_post_new');
         }
         return $this->redirectToRoute('admin_post_index');
     }
     return $this->render('admin/blog/new.html.twig', array('post' => $post, 'form' => $form->createView()));
 }
開發者ID:alisan-alacam,項目名稱:blog,代碼行數:27,代碼來源:BlogController.php

示例9: testRabbitMQ

 public function testRabbitMQ()
 {
     $client = static::createClient();
     $post = new Post();
     $post->setTitle('Lorem ipsum dolor');
     $post->setSlug('Lorem-ipsum-dolor');
     $post->setSummary('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
     $post->setContent('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
     $post->setAuthorEmail('anna_admin@symfony.com');
     $this->entityManager->persist($post);
     $this->entityManager->flush();
     $client->request('POST', '/post/generate_pdf/' . $post->getId());
     $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
     $pdfName = json_decode($client->getResponse()->getContent(), true)['pdfName'];
     $this->entityManager->remove($post);
     $this->entityManager->flush();
     $pdfPath = self::$kernel->getRootDir() . '/../web/downloads/pdf/' . $pdfName . '.pdf';
     sleep(2);
     $this->assertTrue(file_exists($pdfPath));
     unlink($pdfPath);
 }
開發者ID:alfonsomga,項目名稱:symfony.demo.on.roids,代碼行數:21,代碼來源:RabbitMQControllerTest.php

示例10: testElasticSearch

 public function testElasticSearch()
 {
     $client = self::createClient();
     $crawler = $client->request('GET', '/blog/search-results?q=odio');
     $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
     $this->assertEquals('Results for <b>odio</b> (5)', $crawler->filter('h2#results-info>span')->html());
     $randnumber = rand();
     $post = new Post();
     $post->setTitle('Elasticsearch rocks ' . $randnumber);
     $post->setSlug('elasticsearch-rocks-' . $randnumber);
     $post->setSummary('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
     $post->setContent('Lorem ipsum dolor sit amet consectetur adipiscing elit Urna nisl sollicitudin');
     $post->setAuthorEmail('anna_admin@symfony.com');
     $this->entityManager->persist($post);
     $this->entityManager->flush();
     self::populateElasticSearchIndices();
     $crawler = $client->request('GET', '/blog/search-results?q=Elasticsearch rocks ' . $randnumber);
     $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
     $this->assertEquals('Results for <b>Elasticsearch rocks ' . $randnumber . '</b> (1)', $crawler->filter('h2#results-info>span')->html());
     $this->entityManager->remove($post);
     $this->entityManager->flush();
 }
開發者ID:alfonsomga,項目名稱:symfony.demo.on.roids,代碼行數:22,代碼來源:ElasticSearchControllerTest.php

示例11: loadPosts

 private function loadPosts(ObjectManager $manager)
 {
     foreach (range(1, 10) as $i) {
         $post = new Post();
         $post->setTitle($this->getRandomPostTitle());
         $post->setSummary($this->getRandomPostSummary());
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setContent($this->getPostContent());
         $post->setAuthorEmail('anna_admin@symfony.com');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('john_user@symfony.com');
             $comment->setPublishedAt(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $comment->setContent($this->getRandomCommentContent());
             $comment->setPost($post);
             $manager->persist($comment);
             $post->addComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
開發者ID:Arakaki,項目名稱:symfony-demo,代碼行數:23,代碼來源:LoadFixtures.php

示例12: getExamplePostEntity

 public function getExamplePostEntity()
 {
     $post = new Post();
     $post->setTitle('Eros diam egestas libero eu vulputate risus');
     $post->setSlug('eros-diam-egestas-libero-eu-vulputate-risus');
     $post->setSummary('Sed varius a risus eget aliquam Pellentesque et sapien pulvinar consectetur In
         hac habitasse platea dictumst Urna nisl sollicitudin id varius orci quam id turpis Ut eleifend mauris
         et risus ultrices egestas Aliquam sodales odio id eleifend tristique Ut suscipit posuere justo at
         vulputate');
     $post->setContent('Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do eiusmod tempor
         incididunt ut labore et **dolore magna aliqua**: Duis aute irure dolor in
         reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
         Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
         deserunt mollit anim id est laborum.');
     $post->setAuthorEmail('anna_admin@symfony.com');
     $this->entityManager->persist($post);
     $this->entityManager->flush();
     return $post;
 }
開發者ID:alfonsomga,項目名稱:symfony.demo.on.roids,代碼行數:19,代碼來源:RestControllerTest.php


注:本文中的AppBundle\Entity\Post::setAuthorEmail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。