/** * todo check propertier is owner * @param Property $property * @return View */ public function postPropertyAction(Property $property) { $request = null; $input = $request->decodedBody; $account = $request->apiAccount; $validation_url = $input['base_url'] . '/' . self::$verificationFile . '.html'; $property = new Property(); $property->setBaseUrl($input['base_url']); $property->setValidationUrl($validation_url); $property->setAccount($account); // a placeholder for the form $account = new Account(); // createForm is provided by the parent class $form = $this->createForm(new AccountType(), $account); $form->handleRequest($request); $errors = $this->get('validator')->validate($account); if (count($errors) > 0) { return new View($errors, Response::HTTP_UNPROCESSABLE_ENTITY); } $manager = $this->getDoctrine()->getManager(); $manager->persist($account); $manager->flush(); // created => 201 return new View(array('fuzzing' => $account), Response::HTTP_CREATED); }
public function putPropertyVerifyAction(Property $property) { /*$input = $request->decodedBody; $account = $request->apiAccount;*/ $url = $property->getValidationUrl(); $result = $this->verifierCode($url); if ($result) { // created => 201 return new View(array('property' => $property), Response::HTTP_OK); } else { return new View("Sorry but code or url is wrong", Response::HTTP_NOT_IMPLEMENTED); } }
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(); }
/** * @Route("/new/property", name="new_property") */ public function newAction(Request $request) { $suburbId = $request->request->get('suburb'); $suburb = $this->getDoctrine()->getRepository('AppBundle:Suburb')->find($suburbId); $propertyTypeId = $request->request->get('propertyType'); $propertyType = $this->getDoctrine()->getRepository('AppBundle:PropertyType')->find($propertyTypeId); $property = new Property(); $property->setSuburb($suburb); $property->setPropertyType($propertyType); $landSize = $request->request->get('landSize'); $numberOfBathroom = $request->request->get('numberOfBathroom'); $comment = $request->request->get('comment'); $soldPrice = $request->request->get('soldPrice'); $property->setLandSize($landSize); $property->setNumberOfBathRoom($numberOfBathroom); $property->setComment($comment); $property->setSoldPrice($soldPrice); $em = $this->getDoctrine()->getManager(); $em->persist($property); $em->flush(); return $this->render('property.html.twig', array('property' => $property)); }
/** * Add property * * @param \AppBundle\Entity\Property $property * * @return Site */ public function addProperty(\AppBundle\Entity\Property $property) { $property->setSite($this); $this->properties->add($property); return $this; }