コード例 #1
0
 /**
  *
  * @return Response 
  */
 public function createAction()
 {
     $post = new Post();
     $post->setTitle('Demo Blog');
     $post->setBody('Hello Symfony 2');
     $em = $this->getDoctrine()->getManager();
     $em->persist($post);
     $em->flush();
     return new Response('Created product id ' . $post->getId());
 }
コード例 #2
0
 public function load(ObjectManager $manager)
 {
     $post = new Post();
     $post->setTitle('title');
     $post->setBody('body');
     $arrayTags = array();
     $post->getTags($arrayTags);
     $manager->persist($post);
     $manager->flush();
     self::$posts[] = $post;
 }