本文整理汇总了PHP中AppBundle\Entity\Post::setNote方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::setNote方法的具体用法?PHP Post::setNote怎么用?PHP Post::setNote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppBundle\Entity\Post
的用法示例。
在下文中一共展示了Post::setNote方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createAction(Request $request)
{
$user = $this->getUser();
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
throw $this->createAccessDeniedException();
}
/**
* If user already created a post redirect to edit page
*/
if ($user->getPost() == null) {
$em = $this->getDoctrine()->getManager();
$form = $this->createForm(new PostType());
$form->handleRequest($request);
if ($form->isValid()) {
$data = $form->getData();
$post = new Post();
$post->setNote($data->getNote());
$post->setType($data->getType());
$em->persist($post);
$user->setPost($post);
$em->flush();
if ($request->isXmlHttpRequest()) {
$array = array('status' => 200, 'message' => 'Added');
$response = new JsonResponse($array);
return $response;
}
} else {
if ($request->isXmlHttpRequest()) {
$errors = $this->get('form.errorMessages')->getErrorMessages($form);
$array = array('status' => 400, 'errors' => $errors);
$response = new JsonResponse($array);
return $response;
}
}
return $this->render('AppBundle:Post:create.html.twig', array('form' => $form->createView()));
} else {
return $this->redirectToRoute("dashboard_post_edit");
}
}