Question:
Date: 06-03-2019 14:40:01
(In Spanish)
He mirado los if una y otra vez y no logro notar el error, pero me esta saliendo un error en el posman cuando debería de lanzarme un success porque he colocado todos los valores correctamente.
[url=https://ibb.co/MBJ5kHf][/url]
[url=https://ibb.co/8dQHvjz][/url]
[url=https://ibb.co/sP4J3Tg][/url]
[url=https://ibb.co/vqcbtZM][/url]
Debería de lanzarme un success pero me esta lanzando un error[Resolved]
Hola amigos de la comunidad...He mirado los if una y otra vez y no logro notar el error, pero me esta saliendo un error en el posman cuando debería de lanzarme un success porque he colocado todos los valores correctamente.
[url=https://ibb.co/MBJ5kHf][/url]
[url=https://ibb.co/8dQHvjz][/url]
[url=https://ibb.co/sP4J3Tg][/url]
[url=https://ibb.co/vqcbtZM][/url]
public function newAction(Request $request) { $helpers = $this->get("app.helpers"); $hash = $request->get("authorization", null); $authCheck = $helpers->authCheck($hash); if ($authCheck == true) { $identity = $helpers->authCheck($hash, true); $json = $request->get("json", null); if ($json != null) { $json = json_decode($json); $createdAt = new \Datetime('now'); $updatedAt = new \Datetime('now'); $image = null; $video_path = null; $user_id = ($identity->sub != null) ? $identity->sub : null; $title = (isset($params->title)) ? $params->title : null; $description = (isset($params->description)) ? $params->description : null; $status = (isset($params->status)) ? $params->status : null; if ($user_id != null && $title != null) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository("BackendBundle:User")->findOneBy( array( "id" => $user_id )); $video = new Video(); $video->setUser($user); $video->setTitle($title); $video->setDescription($description); $video->setStatus($status); $video->setCreatedAt($createdAt); $video->setUpdatedAt($updatedAt); $em->persist($video); $em->flush(); $video = $em->getRepository("BackendBundle:Video")->findOneBy( array( "user" => $user, "title" => $title, "status" => $status, "createdAt" => $createdAt )); $data = array( "status" => "success", "code" => 200, "data" => $video ); } else { $data = array( "status" => "error", "code" => 400, "msg" => "El video no ha sido creado" ); } } else { $data = array( "status" => "error", "code" => 400, "msg" => "Video no creado, el params ha fallado" ); } } else { $data = array( "status" => "error", "code" => 400, "msg" => "Autorizacion no valida" ); } return $helpers->json($data); }Votes: 0 - Answers: 1 - Views: 6 Share on: Google Facebook Twitter LinkedIn Link
Answers:
-
Date: 06-03-2019 15:12:12 Ya lo he solucionado...
El problema era que no estaba declarando la variableparams
En vez de colocar$params = json_decode($json);
en la linea 25, lo hacia mal colocando$json = json_decode($json);
Votes: 0 - Link answer
To actively participate in the community first must authenticate, enter the system.Sign In