public function store()
 {
     $assoc = true;
     $data = json_decode($this->request->getParameter("json"), $assoc);
     $out = ['title' => $data['title'], 'firstName' => $data['firstName'], 'surname' => $data['surname'], 'emailAddress' => $data['emailAddress'], 'telNumber' => $data['telNumber'], 'contactAddress' => ['firstLine' => $data['firstLine'], 'secondLine' => $data['secondLine'], 'townCity' => $data['townCity'], 'postalCode' => $data['postalCode']]];
     $send = json_encode($out);
     $access = new DataAccess();
     $access->setContentType("application/json");
     $response = $access->post('clients', $send);
     var_dump($response);
     $id = 0;
     if (preg_match('/(201 Created)/', $response)) {
         $response = preg_split("/\n/", $response);
         foreach ($response as $value) {
             if (preg_match("/(Location:)/", $value)) {
                 $parts = preg_split("/\\//", $value);
                 $last = count($parts) - 1;
                 $id = str_replace("\r", "", $parts[$last]);
             }
         }
     }
     $client = ['id' => $id, 'details' => $data];
     session_start();
     $_SESSION['client'] = $client;
 }
 public function store()
 {
     $data = json_decode($this->request->getParameter("json"), true);
     $id = (int) preg_replace('/^category-/', '', $data['category']);
     $dataAccess = new DataAccess();
     $json = $dataAccess->get("category/{$id}");
     $list = json_decode($json, true);
     $category = ['id' => $id, 'name' => $list['name']];
     session_start();
     $_SESSION['category'] = $category;
 }
 public function remove($params)
 {
     $id = $params['id'];
     $da = new DataAccess();
     $path = "item-images/{$id}";
     $response = $da->delete($path);
     // test $response for ok...
     // remove from session.
     $output = ['status' => 'success'];
     $output = json_encode($output);
     $this->response->setContent($output);
 }
 public function store()
 {
     $assoc = true;
     $data = json_decode($this->request->getParameter("json"), $assoc);
     $list = [];
     var_dump($data);
     foreach ($data as $key => $value) {
         $id = (int) preg_replace('/^classification-/', '', $value['classification']);
         $dataAccess = new DataAccess();
         $json = $dataAccess->get("classification/{$id}");
         $list[] = json_decode($json, true);
     }
     session_start();
     $_SESSION['classifications'] = $list;
 }
 public function store()
 {
     $data = json_decode($this->request->getParameter("json"), true);
     foreach ($data as $key => $value) {
         if ($value == true) {
             $id = (int) preg_replace('/^expert-/', '', $value);
         }
     }
     $dataAccess = new DataAccess();
     $json = $dataAccess->get("expert/{$id}");
     $list = json_decode($json, true);
     $expert = ['id' => $id, 'title' => $list['title'], 'firstName' => $list['firstName'], 'surname' => $list['surname'], 'email' => $list['emailAddress']];
     session_start();
     $_SESSION['expert'] = $expert;
 }