Пример #1
0
 /**
  * Handles the requests and returns the json for the response body
  * @param Request    $request
  * @param Repository $repository
  * @param string     $action
  *
  * @return string
  * @throws InvalidArgumentException
  */
 public function handleRequest(Request $request, Repository $repository, $action)
 {
     $commitSize = $this->manager->getBulkCommitSize();
     $documents = $this->requestSerializer->deserializeRequest($request);
     switch ($action) {
         case 'create':
             return $this->create($documents, $repository, $commitSize);
             break;
         case 'update':
             return $this->update($documents, $repository, $commitSize);
             break;
         case 'delete':
             return $this->delete($documents, $repository, $commitSize);
             break;
         default:
             throw new InvalidArgumentException('handleRequest method can only handle `create`, `update` and `delete` actions.');
     }
 }