Ejemplo n.º 1
0
 /**
  * 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);
 }