/** */ public function step2Action(Request $request) { $adData = $request->getSession()->get('ad'); $em = $this->getDoctrine()->getManager(); $vertical = $em->getRepository('Entity:Vertical')->find($adData['vertical_id']); $category1 = $em->getRepository('Entity:Category1')->find($adData['category1_id']); $category2 = $em->getRepository('Entity:Category2')->find($adData['category2_id']); $category3 = $em->getRepository('Entity:Category3')->find($adData['category3_id']); $className = '\\Entity\\' . $vertical->getAdClass(); $formName = 'Rmc\\' . $vertical->getAdClass() . '\\PostBundle\\Form\\' . $vertical->getAdClass() . 'PostType'; $obj = new $className(); $formType = new $formName(); if ($vertical->getAdClass() != 'Ad') { $adObj = new Ad(); $adObj->setVertical($vertical); $adObj->setCategory1($category1); $adObj->setCategory2($category2); $adObj->setCategory3($category3); $adObj->setStatus('A'); $obj->setAd($adObj); } else { $obj->setVertical($vertical); $obj->setCategory1($category1); $obj->setCategory2($category2); $obj->setCategory3($category3); } // Electronics //$obj = new Ad(); //$formType = new AdPostType(); // Car //$obj = new Car(); //$formType = new CarPostType(); $form = $this->createForm($formType, $obj); $form->add('save', SubmitType::class, array('label' => 'Save')); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em->persist($obj); $em->flush(); $solrIndexService = AdSolrIndexServiceFactory::getIndexManager($this->container, $obj->getAd()->getVertical()->getCode()); $solrIndexService->updateSolrIndex($obj); $request->getSession()->getFlashBag()->set('success', 'Your advert has been successfully placed'); return $this->redirectToRoute('rmc_core_base_homepage'); } return $this->render('RmcCoreAdPostBundle:Default:step2.html.twig', array('form' => $form->createView())); }
/** * Remove ads * * @param Ad $ads */ public function removeAd(Ad $ads) { $this->ads->removeElement($ads); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $machineCount = 30; $machine = $this->getReference('machine'); $status = 'A'; $currency = $this->getReference('eur'); $dummyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sollicitudin elit.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ut turpis quis ante mattis luctus.\n Fusce ac tortor purus. Pellentesque blandit scelerisque sagittis. Morbi quis dolor molestie, mattis felis quis, eleifend lorem.\n Fusce rhoncus mauris sit amet sapien feugiat, quis ultricies nunc semper."; $machines = array('agriculture' => array('farming'), 'construction' => array('bagger', 'lader'), 'forestry' => array('forwarder', 'harwarder')); $machineArray = array_keys($machines); $milageArray = array(5000, 10000, 15000, 20000, 25000, 40000, 50000, 55000, 65000, 70000, 75000, 90000, 100000, 125000, 150000); $colorsArray = array('red', 'green', 'blue', 'yellow', 'black', 'orange'); $fuelArray = array('diesel', 'petrol', 'cng', 'lpg', 'electric', 'hybrid'); $ownersArray = array('1', '2', '3', 'more_than_3'); $condtArray = array('new', 'second_hand'); $salvgArray = array('yes', 'no'); $makeArray = array('accord', 'amazon', 'bell', 'atlas', 'becker', 'borco'); for ($i = 1; $i <= $machineCount; $i++) { $mfgYear = rand(date("Y", strtotime("-30 year")), date('Y')); $category = $machineArray[array_rand($machineArray)]; $category2 = $machines[$category][array_rand($machines[$category])]; $adObj4 = new Ad(); $adObj4->setUser($this->getReference('user_normal_' . rand(1, 5))); $adObj4->setVertical($machine); $adObj4->setCategory1($this->getReference($category)); $adObj4->setCategory2($this->getReference($category2)); $adObj4->setStatus($status); $adObj4->setPrice(rand(11111, 999999)); $adObj4->setCurrency($currency); $adObj4->setTitle($category . " " . $category2 . " " . $mfgYear); $adObj4->setDescription($dummyText); $adObj4->setCreatedAt(new \DateTime('NOW')); $manager->persist($adObj4); $manager->flush(); $this->addReference('machine_vertical' . $i, $adObj4); $machineObj = new Machine(); $machineObj->setAd($adObj4); $machineObj->setMfgYear($mfgYear); $machineObj->setMileage($milageArray[array_rand($milageArray)]); $machineObj->setVin(rand(11111111, 99999999)); $machineObj->setPower(rand(111, 9999)); $machineObj->setFuelConsumption(rand(1, 500) . "L"); $machineObj->setCapacity($this->getReference("capacity_" . rand(4, 62))); $machineObj->setModel('random'); $machineObj->setColor($this->getReference($colorsArray[array_rand($colorsArray)])); $machineObj->setMachineMake($this->getReference('machine_' . $makeArray[array_rand($makeArray)])); $machineObj->setFuelType($this->getReference($fuelArray[array_rand($fuelArray)])); $machineObj->setOwners($this->getReference($ownersArray[array_rand($ownersArray)])); $machineObj->setConditions($this->getReference($condtArray[array_rand($condtArray)])); $machineObj->setSalvage($this->getReference('salvage_' . $salvgArray[array_rand($salvgArray)])); $manager->persist($machineObj); $manager->flush(); } }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $carCount = 70; $status = 'A'; $currencyArray = array('eur', 'usd'); $dummyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sollicitudin elit.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ut turpis quis ante mattis luctus.\n Fusce ac tortor purus. Pellentesque blandit scelerisque sagittis. Morbi quis dolor molestie, mattis felis quis, eleifend lorem.\n Fusce rhoncus mauris sit amet sapien feugiat, quis ultricies nunc semper."; $cars = array('audi' => array('A7', 'Q5', '100', 'R8'), 'bmw' => array('I8', 'M1', 'M3', 'X1', 'Z8'), 'toyota' => array('auris', 'dyna', 'hiace'), 'ford' => array('capri'), 'hyundai' => array('atos'), 'renault' => array('fuego'), 'acura' => array('mdx'), 'dodge' => array('avenger'), 'ferrari' => array('f_208'), 'suzuki' => array('alto', 'baleno')); $categoryArray = array_keys($cars); $milageArray = array(5000, 10000, 15000, 20000, 25000, 40000, 50000, 55000, 65000, 70000, 75000, 90000, 100000, 125000, 150000); $engineArray = array(500, 800, 1000, 1200, 2000, 5000, 10000); $colorsArray = array('red', 'green', 'blue', 'yellow', 'black', 'orange'); $fuelArray = array('diesel', 'petrol', 'cng', 'lpg', 'electric', 'hybrid'); $ownersArray = array('1', '2', '3', 'more_than_3'); $airArray = array('manually', 'automatically', 'no'); $condtArray = array('new', 'second_hand'); $typeArray = array('hatchBack', 'coupe', 'sedan', 'suv', 'van'); $salvgArray = array('yes', 'no'); $endYear = date("Y", strtotime("+5 year")); $startYear = date('Y'); $equipArray = array('abs', 'eds', 'seat', 'mirror', 'window'); for ($i = 1; $i <= $carCount; $i++) { $mfgYear = rand(date("Y", strtotime("-30 year")), date('Y')); $adObj1 = new Ad(); $category = $categoryArray[array_rand($categoryArray)]; $category2 = $cars[$category][array_rand($cars[$category])]; $adObj1->setVertical($this->getReference('car')); $adObj1->setUser($this->getReference('user_normal_' . rand(1, 5))); $adObj1->setCategory1($this->getReference($category)); $adObj1->setCategory2($this->getReference($category2)); $adObj1->setStatus($status); $adObj1->setTitle($category . " " . $category2 . " " . $mfgYear); $adObj1->setPrice(rand(11111, 999999)); $adObj1->setCurrency($this->getReference($currencyArray[array_rand($currencyArray)])); $adObj1->setDescription($dummyText); $adObj1->setCreatedAt(new \DateTime('NOW')); $manager->persist($adObj1); $manager->flush(); $carObj = new Car(); $carObj->setAd($adObj1); $carObj->setMfgYear($mfgYear); $carObj->setMileage($milageArray[array_rand($milageArray)]); $carObj->setEngineSize($engineArray[array_rand($engineArray)]); $carObj->setVin(rand(11111111, 99999999)); $carObj->setPower(rand(111, 9999)); $carObj->setFuelConsumption(rand(1, 500) . "L"); $carObj->setDoors(rand(2, 8)); $carObj->setSeats(rand(2, 10)); $carObj->setColor($this->getReference($colorsArray[array_rand($colorsArray)])); $carObj->setFuelType($this->getReference($fuelArray[array_rand($fuelArray)])); $carObj->setOwners($this->getReference($ownersArray[array_rand($ownersArray)])); $carObj->setAirConditioner($this->getReference('air_' . $airArray[array_rand($airArray)])); $carObj->setEmission($this->getReference("eur" . rand(1, 6))); $carObj->setGearType($this->getReference("gear_" . rand(1, 4))); $carObj->setTransmission($this->getReference("trans_" . rand(1, 2))); $carObj->setCapacity($this->getReference("capacity_" . rand(4, 62))); $carObj->setTuvValidity($this->getReference('tuv_' . rand($startYear, $endYear))); $carObj->setConditions($this->getReference($condtArray[array_rand($condtArray)])); $carObj->setCarType($this->getReference('cartype_' . $typeArray[array_rand($typeArray)])); $carObj->setSalvage($this->getReference('salvage_' . $salvgArray[array_rand($salvgArray)])); $equipsArray = array_rand($equipArray, 3); foreach ($equipsArray as $euipment) { $carObj->addCarEquipment($this->getReference('car_eqp_' . $equipArray[$euipment])); } $manager->persist($carObj); $manager->flush(); $this->addReference('car_data_' . $i, $carObj); } }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $commCount = 50; $commercialVehicle = $this->getReference('commercialVehicle'); $status = 'A'; $currencyArray = array('eur', 'usd'); $dummyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sollicitudin elit.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ut turpis quis ante mattis luctus.\n Fusce ac tortor purus. Pellentesque blandit scelerisque sagittis. Morbi quis dolor molestie, mattis felis quis, eleifend lorem.\n Fusce rhoncus mauris sit amet sapien feugiat, quis ultricies nunc semper."; $commercials = array('accord', 'amazon', 'atlas', 'bell', 'bova', 'bobcat', 'barkas', 'bomag', 'doll', 'clark', 'miner'); $milageArray = array(5000, 10000, 15000, 20000, 25000, 40000, 50000, 55000, 65000, 70000, 75000, 90000, 100000, 125000, 150000); $colorsArray = array('red', 'green', 'blue', 'yellow', 'black', 'orange'); $fuelArray = array('diesel', 'petrol', 'cng', 'lpg', 'electric', 'hybrid'); $ownersArray = array('1', '2', '3', 'more_than_3'); $condtArray = array('new', 'second_hand'); $typeArray = array('trailer', 'bus', 'truck', 'tractor'); $salvgArray = array('yes', 'no'); $equipArray = array('airbag', 'abs', 'intarder', 'liftachse', 'heater'); for ($i = 1; $i <= $commCount; $i++) { $mfgYear = rand(date("Y", strtotime("-30 year")), date('Y')); $commercial = $commercials[array_rand($commercials)]; $adObj3 = new Ad(); $adObj3->setUser($this->getReference('user_normal_' . rand(1, 5))); $adObj3->setVertical($commercialVehicle); $adObj3->setCategory1($this->getReference($commercial)); $adObj3->setStatus($status); $adObj3->setPrice(rand(11111, 999999)); $adObj3->setCurrency($this->getReference($currencyArray[array_rand($currencyArray)])); $adObj3->setTitle($commercial . " " . $mfgYear); $adObj3->setDescription($dummyText); $adObj3->setCreatedAt(new \DateTime('NOW')); $manager->persist($adObj3); $manager->flush(); $commObj = new CommercialVehicle(); $commObj->setAd($adObj3); $commObj->setMfgYear($mfgYear); $commObj->setMileage($milageArray[array_rand($milageArray)]); $commObj->setCapacity($this->getReference("capacity_" . rand(4, 62))); $commObj->setVin(rand(11111111, 99999999)); $commObj->setPower(rand(111, 9999)); $commObj->setModel('random' . $i); $commObj->setFuelConsumption(rand(1, 500) . "L"); $commObj->setColor($this->getReference($colorsArray[array_rand($colorsArray)])); $commObj->setFuelType($this->getReference($fuelArray[array_rand($fuelArray)])); $commObj->setOwners($this->getReference($ownersArray[array_rand($ownersArray)])); $commObj->setConditions($this->getReference($condtArray[array_rand($condtArray)])); $commObj->setCommercialVehicleType($this->getReference('commtype_' . $typeArray[array_rand($typeArray)])); $commObj->setSalvage($this->getReference('salvage_' . $salvgArray[array_rand($salvgArray)])); $equipsArray = array_rand($equipArray, 3); foreach ($equipsArray as $euipment) { $commObj->addCommercialVehicleEquipment($this->getReference('comm_eqp_' . $equipArray[$euipment])); } $manager->persist($commObj); $manager->flush(); $this->addReference('comm_data_' . $i, $commObj); } }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $bikeCount = 50; $status = 'A'; $currencyArray = array('eur', 'usd'); $dummyText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget sollicitudin elit.\n Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ut turpis quis ante mattis luctus.\n Fusce ac tortor purus. Pellentesque blandit scelerisque sagittis. Morbi quis dolor molestie, mattis felis quis, eleifend lorem.\n Fusce rhoncus mauris sit amet sapien feugiat, quis ultricies nunc semper."; $bikes = array('bajaj', 'yamaha', 'amerigo', 'bimota', 'berva', 'ducati', 'bunell', 'gilera', 'eagle', 'honda'); $milageArray = array(5000, 10000, 15000, 20000, 25000, 40000, 50000, 55000, 65000, 70000, 75000, 90000, 100000, 125000, 150000); $colorsArray = array('red', 'green', 'blue', 'yellow', 'black', 'orange'); $fuelArray = array('diesel', 'petrol', 'cng', 'lpg', 'electric', 'hybrid'); $ownersArray = array('1', '2', '3', 'more_than_3'); $condtArray = array('new', 'second_hand'); $typeArray = array('enduro', 'trailer_sidecar', 'motocross', 'oldtimer', 'scooter'); $salvgArray = array('yes', 'no'); $equipArray = array('handguards', 'abs', 'antitheft', 'disc', 'topcase'); for ($i = 1; $i <= $bikeCount; $i++) { $mfgYear = rand(date("Y", strtotime("-30 year")), date('Y')); $bike = $bikes[array_rand($bikes)]; $adObj2 = new Ad(); $adObj2->setUser($this->getReference('user_normal_' . rand(1, 5))); $adObj2->setVertical($this->getReference('bike')); $adObj2->setCategory1($this->getReference($bike)); $adObj2->setStatus($status); $adObj2->setTitle($bike . " " . $mfgYear); $adObj2->setPrice(rand(11111, 999999)); $adObj2->setCurrency($this->getReference($currencyArray[array_rand($currencyArray)])); $adObj2->setDescription($dummyText); $adObj2->setCreatedAt(new \DateTime('NOW')); $manager->persist($adObj2); $manager->flush(); $bikeObj1 = new Bike(); $bikeObj1->setAd($adObj2); $bikeObj1->setMfgYear($mfgYear); $bikeObj1->setMileage($milageArray[array_rand($milageArray)]); $bikeObj1->setModel('Random' . $i); $bikeObj1->setVin(rand(11111111, 99999999)); $bikeObj1->setPower(rand(111, 9999)); $bikeObj1->setDisplacement(rand(1, 99999)); $bikeObj1->setFuelConsumption(rand(1, 500) . "L"); $bikeObj1->setColor($this->getReference($colorsArray[array_rand($colorsArray)])); $bikeObj1->setFuelType($this->getReference($fuelArray[array_rand($fuelArray)])); $bikeObj1->setOwners($this->getReference($ownersArray[array_rand($ownersArray)])); $bikeObj1->setConditions($this->getReference($condtArray[array_rand($condtArray)])); $bikeObj1->setBikeType($this->getReference('biketype_' . $typeArray[array_rand($typeArray)])); $bikeObj1->setSalvage($this->getReference('salvage_' . $salvgArray[array_rand($salvgArray)])); $equipsArray = array_rand($equipArray, 3); foreach ($equipsArray as $euipment) { $bikeObj1->addBikeEquipment($this->getReference('bike_eqp_' . $equipArray[$euipment])); } $manager->persist($bikeObj1); $manager->flush(); $this->addReference('bike_data_' . $i, $bikeObj1); } }