Exemple #1
0
 public function load(ObjectManager $manager)
 {
     $Audi = new Brand();
     $Audi->setTitle("Audi");
     $audi_a4 = new Model();
     $audi_a6 = new Model();
     $audi_a4->setTitle("A4");
     $audi_a6->setTitle("A6");
     $audi_a4->setBrand($Audi);
     $audi_a6->setBrand($Audi);
     $Audi->addModel($audi_a4);
     $Audi->addModel($audi_a6);
     $manager->persist($Audi);
     $manager->persist($audi_a6);
     $manager->persist($audi_a4);
     $BMW = new Brand();
     $BMW->setTitle("BMW");
     $e46 = new Model();
     $e55 = new Model();
     $e46->setTitle("e46");
     $e55->setTitle("e55");
     $e46->setBrand($BMW);
     $e55->setBrand($BMW);
     $BMW->addModel($e46);
     $BMW->addModel($e55);
     $manager->persist($BMW);
     $manager->persist($e46);
     $manager->persist($e55);
     $manager->flush();
 }
Exemple #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $models = [];
     $brand = $this->getReference('brand-yamaha');
     $category = $this->getReference('category-moto');
     foreach (['YZF-R6', 'YZF-R1'] as $modelName) {
         $model = new Model();
         $model->setName($modelName);
         $model->setBrand($brand);
         $model->addCategory($category);
         $model->setSlug(sprintf('%s/%s', $brand->getSlug(), strtolower($modelName)));
         $manager->persist($model);
         $this->addReference('model-' . $modelName, $model);
     }
     $manager->flush();
 }