本文整理汇总了PHP中AppBundle\Entity\Post::setCreatedAt方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setCreatedAt方法的具体用法?PHP Post::setCreatedAt怎么用?PHP Post::setCreatedAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setCreatedAt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newAction
/**
* Displays a form to create a new Post entity.
*
* @Route("/new", name="admin_post_new")
* @Method("GET")
* @Template()
*/
public function newAction()
{
$entity = new Post();
$entity->setCreatedAt();
$form = $this->createCreateForm($entity);
return array('entity' => $entity, 'form' => $form->createView());
}
示例2: load
public function load(ObjectManager $manager)
{
$faker = \Faker\Factory::create();
for ($i = 1; $i <= 1000; $i++) {
$post = new Post();
$post->setTitle($faker->sentence(15));
$post->setLead($faker->text(300));
$post->setContent($faker->text(700));
$post->setCreatedAt($faker->dateTimeThisMonth);
$manager->persist($post);
}
$manager->flush();
}
示例3: 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);
}
示例4: setCreatedAt
/**
* {@inheritDoc}
*/
public function setCreatedAt($createdAt)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreatedAt', [$createdAt]);
return parent::setCreatedAt($createdAt);
}