setContent() публичный Метод

public setContent ( $content )
Пример #1
0
 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('*****@*****.**');
         $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('*****@*****.**');
             $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();
 }
Пример #2
0
 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('*****@*****.**');
         $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('*****@*****.**');
             $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();
 }
Пример #3
0
 public function load(ObjectManager $manager)
 {
     // TODO: Implement load() method.
     $category = new Category();
     $category->setName('Default');
     $manager->persist($category);
     foreach (range(1, 100) as $i) {
         $post = new Post();
         $post->setTitle($this->getPostTitle());
         $post->setSlug($this->container->get('slugger')->slugify($post->getTitle()));
         $post->setImage('post.jpeg');
         $post->setContent($this->getPostContent());
         $post->setAuthor('gunyem');
         $post->setCreated(new \DateTime('now - ' . $i . 'days'));
         $post->setUpdated(new \DateTime('now - ' . $i . 'days'));
         $post->setCategory($category);
         foreach (range(1, 10) as $j) {
             $comment = new Comment();
             $comment->setPost($post);
             $comment->setContent($this->getPostTitle());
             $comment->setAuthor('gunyem');
             $comment->setCreated(new \DateTime('now + ' . ($i + $j) . 'seconds'));
             $manager->persist($comment);
             $post->createComment($comment);
         }
         $manager->persist($post);
     }
     $manager->flush();
 }
Пример #4
0
 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('*****@*****.**');
         $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('*****@*****.**');
             $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) ? '*****@*****.**' : '*****@*****.**');
             $vote->setPost($post);
             $vote->setVote(rand(0, 1));
         }
         $manager->persist($post);
         $category->addPost($post);
     }
     $manager->flush();
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $comment = new Comment();
     $comment->setAuthor($this->getReference('user'));
     $comment->setContent('Commentaire babla bla bla Beer');
     $comment->setArticle($this->getReference('article'));
     $manager->persist($comment);
     $manager->flush();
     $this->addReference('comment', $comment);
 }
Пример #6
0
 public function testSubmitValidData()
 {
     $formData = array('content' => 'Test content text');
     $form = $this->factory->create(CommentType::class);
     $object = new Comment();
     $object->setContent('Test content text');
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Пример #7
0
 /**
  * @param int    $ideaId
  * @param string $content
  * @param bool   $isPrivate
  *
  * @return Comment
  * @throws \Exception
  */
 public function comment($ideaId, $content, $isPrivate)
 {
     $idea = $this->getIdea($ideaId);
     if ($idea instanceof Idea === false) {
         throw new \Exception("Unknown Idea[id={$ideaId}] aka 'I have no idea!'");
     }
     $user = $this->getAuthenticatedUser();
     $this->ensureAuthenticated($user);
     $comment = new Comment();
     $comment->setIdea($idea);
     $comment->setContent($content);
     $comment->setUser($user);
     $comment->setPrivate($isPrivate);
     $comment->setCreatedAt(new \DateTime());
     $this->entityManager->persist($comment);
     $this->entityManager->flush($comment);
     return $comment;
 }
 public function load(ObjectManager $manager)
 {
     for ($i = 0; $i < 40; $i++) {
         $article = new Article();
         $article->setTitle('News' . $i);
         $article->setContent('This is default content');
         $article->setDatetime(new \DateTime('- ' . rand(1, 4) . ' day'));
         $commentA = new Comment();
         $commentA->setAuthor('Author');
         $commentA->setContent('Comment .... default');
         $manager->persist($commentA);
         $article->addComment($commentA);
         $commentB = new Comment();
         $commentB->setAuthor('Author' . $i);
         $commentB->setContent('Comment .... default');
         $manager->persist($commentB);
         $article->addComment($commentB);
         $manager->persist($article);
     }
     $manager->flush();
 }
Пример #9
0
 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('*****@*****.**');
         $post->setPublishedAt(new \DateTime('now - ' . $i . 'days'));
         foreach (range(1, 5) as $j) {
             $comment = new Comment();
             $comment->setAuthorEmail('*****@*****.**');
             $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();
 }
Пример #10
0
 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 1; $i <= 24; $i++) {
         $article = new Article();
         // $article->setSlug('article' . $i);
         $article->setSummary($faker->sentences(10, true));
         $article->setContent($faker->text(3000));
         $article->setTitle($faker->sentence());
         $slug = $this->container->get('app.slugger')->slugify($article->getTitle());
         $article->setSlug($slug);
         $article->setAuthorEmail('*****@*****.**');
         $article->setPathToImage('images/foto_' . $i . '.jpg');
         for ($j = 1; $j <= 5; $j++) {
             $comment = new Comment();
             $comment->setContent($faker->sentences(5, true));
             //$comment->setPublishedAt(new \DateTime('now'));
             $comment->setArticle($article);
             $comment->setAuthorEmail('*****@*****.**');
             $article->addComment($comment);
             $manager->persist($comment);
         }
         $manager->persist($article);
         $arrayId = array();
         $k = rand(1, 10);
         while (count($arrayId) < $k) {
             $id = rand(1, 50);
             if (array_search($id, $arrayId) === false) {
                 $arrayId[] = $id;
                 $tagFromBase = $this->getReference("tag {$id}");
                 $article->addTag($tagFromBase);
                 $tagFromBase->getArticles()->add($article);
             }
         }
     }
     $manager->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function setContent($content)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setContent', array($content));
     return parent::setContent($content);
 }
 public function getExampleCommentEntity()
 {
     $comment = new Comment();
     $comment->setContent('Lorem ipsum dolor sit amet consectetur.');
     $comment->setAuthorEmail('*****@*****.**');
     return $comment;
 }