public function load(ObjectManager $manager) { $propertyType1 = new PropertyType(); $propertyType1->setName('house'); $suburb1 = new Suburb(); $suburb1->setName('Bentleigh'); $property1 = new Property(); $property1->setLandSize('230'); $property1->setNumberOfBathRoom(2); $property1->setComment('near highway'); $property1->setSoldPrice(750000); $property1->setAddress('4 Milton Street Bentleigh'); $property1->setPropertyType($propertyType1); $property1->setSuburb($suburb1); $area1 = new Area(); $area1->setName('kitchen'); $area1->setLength(5.2); $area1->setWidth(4); $area1->setProperty($property1); $area2 = new Area(); $area2->setName('living Room'); $area2->setLength(3.45); $area2->setWidth(4.23); $area2->setProperty($property1); $area3 = new Area(); $area3->setName('bed room'); $area3->setProperty($property1); $area3->setWidth(3.45); $area3->setLength(4.12); $property1->addArea($area1); $property1->addArea($area2); $property1->addArea($area3); $manager->persist($propertyType1); $manager->persist($suburb1); $manager->persist($area1); $manager->persist($area2); $manager->persist($area3); $manager->persist($property1); $manager->flush(); }
private function storeAreaDetails() { $i = 0; $em = $this->doctrine->getEntityManager(); $repository = $em->getRepository('AppBundle:Area'); foreach ($this->areaDetails as $areaCode => $details) { if (++$i == 1) { print_r($details); } $currentArea = $repository->findOneByCode($areaCode); if (!$currentArea) { $currentArea = new Area(); } $currentArea->setCode($areaCode); $currentArea->setGooglePlaceIdentifier($details['place_id']); $currentArea->setCenterLatitude($details['geometry']['location']['lat']); $currentArea->setCenterLongitude($details['geometry']['location']['lng']); $currentArea->setNorthEdgeLatitude($details['geometry']['viewport']['northeast']['lat']); $currentArea->setEastEdgeLongitude($details['geometry']['viewport']['northeast']['lng']); $currentArea->setSouthEdgeLatitude($details['geometry']['viewport']['southwest']['lat']); $currentArea->setWestEdgeLongitude($details['geometry']['viewport']['southwest']['lng']); $currentArea->setToponymLong($details['address_components'][0]['long_name']); $currentArea->setToponymShort($details['address_components'][0]['short_name']); $em->persist($currentArea); } $em->flush(); }