Пример #1
0
 public function postAction(Request $request, Application $app)
 {
     $document = new Document();
     $values = $this->filterValues($request);
     $document->fromArray($request->request->all(), \BasePeer::TYPE_FIELDNAME);
     if (true !== ($errors = $app['document_validator']($document))) {
         return $app['view_handler']->handle($errors, 400);
     }
     $app['document_repository']->add($document);
     return $app['view_handler']->handle($document, 201, ['Location' => $app['serializer']->getLinkHelper()->getLinkHref($document, 'self', true)]);
 }
Пример #2
0
 private function createDocument($id, $title, $body)
 {
     $document = new Document();
     $document->fromArray(['id' => $id, 'title' => $title, 'body' => $body, 'created_at' => new \DateTime(), 'updated_at' => new \DateTime()]);
     return $document;
 }