/** * {@inheritDoc} */ public function load(ObjectManager $manager) { for ($x = 0; $x < 50; $x++) { $feature1 = new Feature(); $feature1->setName("Name 1"); $feature2 = new Feature(); $feature2->setName("Name 2"); $product = new Product(); $product->setDescription("Description " . $x)->setName("Name " . $x)->setPrice($x)->setFeatures(array($feature1, $feature2)); $manager->persist($product); } $manager->flush(); }
/** * * @Route("/admin/feature/new/{featureSectionId}", name="admin_feature_new") */ public function newAction(Request $request, $featureSectionId) { $feature = new Feature(); $featureSection = $this->getDoctrineRepo('AppBundle:FeatureSection')->find($featureSectionId); $feature->setFeatureSection($featureSection); //when the form is posted this method prefills entity with data from form $form->handleRequest($request); if ($form->isValid()) { //check if there is file $em = $this->getDoctrine()->getManager(); // save to db $em->persist($feature); $em->flush(); return $this->redirect($this->generateUrl('admin_feature_list', array('featureSectionId' => $featureSectionId))); } return $this->render('admin/feature/new.html.twig', array('form' => $form->createView(), 'featureSectionId' => $featureSectionId)); }
public function load(ObjectManager $manager) { for ($i = 0; $i < 40; $i++) { $product = new Product(); $product->setName('Name Product ' . $i); $featureA = new Feature(); $featureA->setName('Description'); $featureA->setDescription("This is a feature's description"); $featureA->setProduct($product); $manager->persist($featureA); $product->addFeature($featureA); $featureB = new Feature(); $featureB->setName('Warranty'); $featureB->setDescription("This is a warranty's description"); $featureB->setProduct($product); $manager->persist($featureB); $product->addFeature($featureB); $manager->persist($product); } $manager->flush(); }
/** * Set features * * @param Feature $feature * * @return Quest */ public function setFeature(Feature $feature = null) { $this->feature = $feature; $feature->incrementLevel(); return $this; }