当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::setCreated方法代码示例

本文整理汇总了PHP中AppBundle\Entity\Post::setCreated方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setCreated方法的具体用法?PHP Post::setCreated怎么用?PHP Post::setCreated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppBundle\Entity\Post的用法示例。


在下文中一共展示了Post::setCreated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAction

 /**
  * @Route("/create", name="create_objects")
  *
  * @Rest\View()
  *
  * @return Response
  */
 public function createAction()
 {
     // We need an entity manager here
     $em = $this->getDoctrine()->getManager();
     // First, we try to create a post
     $post = new Post();
     $post->setTitle('Hello World');
     $post->setContent('This is a hello world post');
     $post->setCreated(new \DateTime());
     $em->persist($post);
     // Create new post log object
     $postLog = new PostLog();
     $postLog->setMessage('A new post was created');
     $postLog->setCreated(new \DateTime());
     $postLog->setParent($post);
     $em->persist($postLog);
     // Try to create a category
     $category = new Category();
     $category->setTitle('A Category');
     $category->setDescription('A category to created');
     $em->persist($category);
     // Create new category log object
     $categoryLog = new CategoryLog();
     $categoryLog->setMessage('A new category was created');
     $categoryLog->setCreated(new \DateTime());
     $categoryLog->setParent($category);
     $em->persist($categoryLog);
     // Actually store all the entities to the database
     // to get id of the post and the category
     $em->flush();
     return ['Done'];
 }
开发者ID:vutung2311,项目名称:sf2_playground,代码行数:39,代码来源:DefaultController.php

示例2: load

 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();
 }
开发者ID:red4r00t,项目名称:Blog,代码行数:29,代码来源:LoadFixtures.php

示例3: load

 public function load(ObjectManager $manager)
 {
     foreach ($this->getData() as $payload) {
         $post = new Entity\Post();
         $post->setTitle($payload[0]);
         $post->setContent($payload[1]);
         $post->setCreated($payload[2]);
         $manager->persist($post);
     }
     $manager->flush();
 }
开发者ID:Wobbly-Wibbly,项目名称:sfTestProject,代码行数:11,代码来源:Post.php


注:本文中的AppBundle\Entity\Post::setCreated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。