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


PHP Post::setUser方法代码示例

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


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

示例1: testSetUser

 public function testSetUser()
 {
     // new entity
     $post = new Post();
     // dummy entity
     $user = new User();
     $user->setFirstName("Ole");
     // Use the setUser method
     $post->setUser($user);
     // Assert the result
     $this->assertEquals($user, $post->getUser());
 }
开发者ID:vegardbb,项目名称:webpage,代码行数:12,代码来源:PostEntityUnitTest.php

示例2: create

 public function create(User $user, $title, $url, $tag)
 {
     if ($errors = $this->getErrors($title, $url, $tag)) {
         throw new ServiceException($errors);
     }
     $post = new Post();
     $post->setUser($user);
     $post->setTitle($title);
     $post->setUrl($url);
     $post->setTag($this->formatTag($tag));
     $post->setUpvoteTotal(0);
     $post->setCreatedAt(new \DateTime());
     return $this->repository->create($post);
 }
开发者ID:matheusgontijo,项目名称:MageBrazuca,代码行数:14,代码来源:PostService.php

示例3: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $post = new Post();
     $post->setTitle('Man must explore, and this is exploration at its greatest');
     $post->setDescription('Never in all their history have men been able truly to conceive of 
                             the world as one: a single sphere, a globe, having the qualities of 
                             a globe, a round earth in which all the directions eventually meet, 
                             in which there is no center because every point, or none, is center — 
                             an equal earth which all men occupy as equals. The airman\'s earth, if
                             free men make it, will be truly round: a globe in practice, not in theory.');
     $post->setUser($manager->merge($this->getReference('super_admin_user')));
     $post->setIsActive(1);
     $post->setCreatedOn(new \DateTime());
     $post->setUpdatedOn(new \DateTime());
     $post1 = new Post();
     $post1->setTitle('New in Symfony 2.6: Bootstrap form theme');
     $post1->setDescription('Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing 
                             responsive, mobile first projects on the web. Bootstrap is so widely used that it 
                             has become the de facto standard for frontend development. That\'s why Symfony 2.6 
                             will include a new form theme designed for Bootstrap 3.');
     $post1->setUser($manager->merge($this->getReference('super_admin_user')));
     $post1->setIsActive(1);
     $post1->setCreatedOn(new \DateTime());
     $post1->setUpdatedOn(new \DateTime());
     $post2 = new Post();
     $post2->setTitle('Symfony Doctine data fixtures');
     $post2->setDescription('Fixtures are used to load a controlled set of data into a database. This data 
                             can be used for testing or could be the initial data required for the application
                             to run smoothly. Symfony2 has no built in way to manage fixtures but Doctrine2 has 
                              a library to help you write fixtures for the Doctrine ORM or ODM.');
     $post2->setUser($manager->merge($this->getReference('super_admin_user')));
     $post2->setIsActive(1);
     $post2->setCreatedOn(new \DateTime());
     $post2->setUpdatedOn(new \DateTime());
     $manager->persist($post);
     $manager->persist($post1);
     $manager->persist($post2);
     $manager->flush();
 }
开发者ID:anilchauhan-cuelogic,项目名称:Blog-app,代码行数:42,代码来源:LoadPostData.php


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