Пример #1
0
 public function load(ObjectManager $manager)
 {
     $listAdverts = array(array('date' => new \Datetime('2015-08-15'), 'title' => 'Développeur Symfony2', 'author' => 'Gabriel', 'content' => 'Recherche développeur Symfony2', 'category' => 'Développement web', 'updatedAt' => new \Datetime('2015-08-15')), array('date' => new \Datetime('2015-09-15'), 'title' => 'Alternant IT', 'author' => 'Marie', 'content' => 'Recherche alternant IT', 'category' => 'Développement web', 'updatedAt' => new \Datetime('2015-09-15')), array('date' => new \Datetime('2014-08-17'), 'title' => 'Développeur web', 'author' => 'Thomas', 'content' => 'HTML/Js/CSS/HTML/jQuery/Java EE', 'category' => 'Développement web', 'updatedAt' => new \Datetime('2015-08-17')), array('date' => new \Datetime('2015-09-05'), 'title' => 'Développeur mobile Android', 'author' => 'Henry', 'content' => 'Recherche développeur mobile Android Java/Phonegap', 'category' => 'Développement mobile', 'updatedAt' => new \Datetime('2015-09-05')), array('date' => new \Datetime('2015-09-14'), 'title' => 'Web Designer pour startup dynamique', 'author' => 'Gabriel', 'content' => 'Recherche Web Designer pour startup dynamique', 'category' => 'Graphisme', 'updatedAt' => new \Datetime('2015-09-14')));
     foreach ($listAdverts as $advert) {
         $ad = new Advert();
         $ad->setDate($advert['date']);
         $ad->setTitle($advert['title']);
         $ad->setContent($advert['content']);
         $ad->setAuthor($advert['author']);
         $ad->setUpdatedAt($advert['updatedAt']);
         $manager->persist($ad);
     }
     $manager->flush();
 }