/**
  * {@inheritDoc}
  */
 public function remove(Document $document)
 {
     foreach ($this->documents as $id => $aDocument) {
         if ($document->isEqualTo($aDocument)) {
             unset($this->documents[$id]);
             break;
         }
     }
 }
 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)]);
 }
Exemple #3
0
 /**
  * @return boolean
  */
 public function isEqualTo(Document $document)
 {
     return $this->getId() === $document->getId();
 }
 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;
 }
 /**
  * {@inheritDoc}
  */
 public function remove(Document $document)
 {
     $document->delete();
 }