return $persons;
}
+ /**
+ * @Rest\Put(
+ * path = "/api/person/{id}/online",
+ * name = "set_person_online"
+ * )
+ * @Rest\View(StatusCode = Response::HTTP_CREATED)
+ */
+ public function onlinePersonAction(Request $request)
+ {
+ //TODO: check that the authenticated user have the same id
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App:Person')->find($request->get('id'));
+
+ if (empty($person)) {
+ return $this->PersonNotFound();
+ }
+
+ $person->setOnline(true);
+
+ $em->merge($person);
+ $em->flush();
+ }
+
+ /**
+ * @Rest\Put(
+ * path = "/api/person/{id}/offline",
+ * name = "set_person_offline"
+ * )
+ * @Rest\View(StatusCode = Response::HTTP_CREATED)
+ */
+ public function offlinePersonAction(Request $request)
+ {
+ //TODO: check that the authenticated user have the same id
+ $em = $this->getDoctrine()->getManager();
+ $person = $em->getRepository('App:Person')->find($request->get('id'));
+
+ if (empty($person)) {
+ return $this->PersonNotFound();
+ }
+
+ $person->setOnline(false);
+
+ $em->merge($person);
+ $em->flush();
+ }
+
private function PersonNotFound() {
return View::create(['message' => 'Person not found'], Response::HTTP_NOT_FOUND);
}