示例#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();
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     foreach (['Yamaha', 'Honda', 'Suzuki', 'Kawasaki'] as $name) {
         $brand = new Brand($name);
         $brand->setSlug(strtolower($name));
         $manager->persist($brand);
         $this->addReference('brand-' . strtolower($name), $brand);
     }
     $manager->flush();
 }
示例#3
0
 /**
  * @Route("/insert/brand", name="insert_brand")
  */
 public function insertBrandAction(Request $request)
 {
     $brand = new Brand();
     $brand->setAdded(new \DateTime('now'));
     $brand->setAdminId($this->getUser()->getId());
     $form = $this->createForm(BrandType::class, $brand);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($brand);
         $em->flush();
         return $this->redirectToRoute('insert_brand');
     }
     $repository = $this->getDoctrine()->getRepository('AppBundle:Brand');
     $brands = $repository->findAll();
     return $this->render('brand/insert.html.twig', array('form' => $form->createView(), 'brands' => $brands));
 }
示例#4
0
文件: Template.php 项目: Cartesia/01
 /**
  * Add brands
  *
  * @param \AppBundle\Entity\Brand $brands
  * @return Template
  */
 public function addBrand(\AppBundle\Entity\Brand $brands)
 {
     $this->brands[] = $brands;
     $brands->addTemplate($this);
     return $this;
 }