Ejemplo n.º 1
0
 /**
  * @param Request $request
  *
  * @return Response
  */
 public function save(Request $request)
 {
     $requestContent = json_decode($request->getContent());
     try {
         if (isset($requestContent->daughters)) {
             $this->service->queueSaveInBulk($requestContent);
         } else {
             $this->service->save(new Organization($requestContent->org_name));
             $this->organizationRepository->commit();
         }
     } catch (\InvalidArgumentException $e) {
         return new Response(null, Response::HTTP_BAD_REQUEST);
     } catch (UniqueConstraintViolationException $e) {
         return new Response(null, Response::HTTP_CONFLICT);
     }
     return new Response(null, Response::HTTP_CREATED);
 }
Ejemplo n.º 2
0
 /**
  * @param $data
  */
 public function saveInBulk($data)
 {
     $this->persistRecursive($data['org_name'], $data['daughters']);
     $this->repository->commit();
 }