/**
  * @param array    $data
  * @param          $className
  * @param callable $callable
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function get(array $data, $className, callable $callable)
 {
     try {
         DataObject::assertPost($data, $this->serializer, $className, $this->errorBag);
         $values = DataObject::getAttributes($data, $this->serializer);
         $model = $callable($data, $values, $this->errorBag);
         $response = $this->resourceCreated($this->serializer->serialize($model));
     } catch (Exception $e) {
         $response = $this->getErrorResponse($e, $this->errorBag);
     }
     return $response;
 }
 /**
  * @param          $id
  * @param array    $data
  * @param          $className
  * @param callable $findOneCallable
  * @param callable $update
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function get($id, array $data, $className, callable $findOneCallable, callable $update)
 {
     try {
         DataObject::assertPut($data, $this->serializer, $className, $this->errorBag);
         $model = $findOneCallable();
         if (empty($model)) {
             $mapping = $this->serializer->getTransformer()->getMappingByClassName($className);
             return $this->resourceNotFound(new ErrorBag([new NotFoundError($mapping->getClassAlias(), $id)]));
         }
         $values = DataObject::getAttributes($data, $this->serializer);
         $update($model, $values, $this->errorBag);
         $response = $this->resourceUpdated($this->serializer->serialize($model));
     } catch (Exception $e) {
         $response = $this->getErrorResponse($e);
     }
     return $response;
 }
 public function testGetAttributes()
 {
     $data = ['type' => 'post', 'attributes' => ['title' => 'My first blog post', 'content' => 'Ever heard of Lorem Ipsum?', 'author' => 1, 'comments' => []]];
     $attributes = DataObject::getAttributes($data, $this->serializer);
     $this->assertNotEmpty($attributes);
 }