From POSTMAN I send the following POST data to create a 'singlesku' document:
{
"brand": "The Brand",
"proddesc": "Just a description!!!",
"quantity": 4,
"warranty": 5,
"isUnique": true,
"googleGtin": "GTin from Google",
"physicalAttributes": {
"width": 12.5,
"depth": 13.52,
"height": 28.654,
"weight": 543.97
}
}
The 'singlesku' document is successfully created in Mongo yet with no embedded 'PhysicalAttributes' data.
The JSON returned by Apigility is the following:
{
_isUnique: true
googleGtin: "GTin from Google"
id: "53c7887f05e17e65840041a8"
brand: "The Brand"
proddesc: "Just a description!!!"
quantity: 4
warranty: 5
-_physicalAttributes: {
width: 12.5
depth: 13.52
height: 28.654
weight: 543.97
}
-_links: {
-self: {
href: "http:\/\/localhost:8888\/api\/singlesku\/53c7887f05e17e65840041a8"
}
}
}
Hi veewee, sorry to bother again. I cannot get my head around the hydration of 'embedded docs' working with 'zf-apigility-doctrine'.
I have have a MappedSuperclass holding an EmbedDocument as per below code: /**
@ODM\InheritanceType("COLLECTION_PER_CLASS") */ abstract class Item {
/* @ODM\Id / protected $id;
/* @ODM\Field(type="string") / protected $brand;
/* @ODM\Field(type="string") / protected $proddesc;
/* @ODM\Field(type="int") / protected $quantity;
/* @ODM\Field(type="int") / protected $warranty;
/* @ODM\EmbedOne(targetDocument="PhysicalAttributes", strategy="set") / protected $physicalAttributes;
... getters and setters }
The embedded doc is defined like this:
/**
*/ class PhysicalAttributes {
/* @ODM\Field(type="float") / private $width;
/* @ODM\Field(type="float") / private $depth;
/* @ODM\Field(type="float") / private $height;
/* @ODM\Field(type="float") / private $weight; ... getters and setters }
The concrete child is a very simple doc with 2 params as follow: /**
@ODM\Document(collection="singlesku") */ class SingleSku extends Item {
/* @ODM\Field(type="boolean") / protected $isUnique;
/* @ODM\Field(type="string") / protected $googleGtin;
...getters and setters }
From POSTMAN I send the following POST data to create a 'singlesku' document: { "brand": "The Brand", "proddesc": "Just a description!!!", "quantity": 4, "warranty": 5, "isUnique": true, "googleGtin": "GTin from Google", "physicalAttributes": { "width": 12.5, "depth": 13.52, "height": 28.654, "weight": 543.97 } }
The 'singlesku' document is successfully created in Mongo yet with no embedded 'PhysicalAttributes' data.
The JSON returned by Apigility is the following: { _isUnique: true googleGtin: "GTin from Google" id: "53c7887f05e17e65840041a8" brand: "The Brand" proddesc: "Just a description!!!" quantity: 4 warranty: 5 -_physicalAttributes: { width: 12.5 depth: 13.52 height: 28.654 weight: 543.97 } -_links: { -self: { href: "http:\/\/localhost:8888\/api\/singlesku\/53c7887f05e17e65840041a8" } } }
Any help appreciated, as usual.