public function load(ObjectManager $em)
 {
     $cat = new TimedThing();
     $cat->setName('Edgar the Cat');
     $cat->setContent('Edgar is happy');
     $bull = new TimedThing();
     $bull->setName('Joe the bull');
     $bull->setContent('Joe is sad');
     $em->persist($cat);
     $em->persist($bull);
     $em->flush();
 }
 public function createAction()
 {
     $em = $this->get('doctrine')->getEntityManager();
     // Let's create a new timed thing
     // note that we don't set the creation date. It will be added
     // automatically by the Doctrine extension based on the
     // mapping.
     $thing = new TimedThing();
     $thing->setName('Lorem ' . uniqid());
     $thing->setContent('Lorem ipsum ' . uniqid());
     // This does not actually save the entity but rather mark it
     // as "should-be-saved-on-the-next-flush"
     $em->persist($thing);
     // Now we save everything: let's flush!
     $em->flush();
     return $this->render('KnpIpsumBundle:GedmoExtensions:create.html.twig', array('thing' => $thing));
 }
Exemple #3
0
 /**
  * @Given /^there are (\d+) timed things in database$/
  */
 public function thereAreTimedThingsInDatabase($count)
 {
     $em = $this->getEntityManager();
     $em->createQuery('DELETE KnpIpsumBundle:TimedThing')->execute();
     for ($i = 0; $i < intval($count); $i++) {
         $thing = new TimedThing();
         $thing->setName('Lorem #' . $i);
         $thing->setContent('text #' . $i);
         $em->persist($thing);
     }
     $em->flush();
 }