dev-master
9999999-dev
MIT
The Requires
by Shingo Kumagai
1.x-dev
1.9999999.9999999.9999999-dev
MIT
The Requires
by Shingo Kumagai
WARNING: This is highly experimental stuff that isn't ready for production use yet., (*1)
Siren support for BEAR.Sunday, (*3)
Siren renderer, (*4)
It overrides default renderer and represents your resource in Siren format., (*5)
Siren [https://github.com/kevinswiber/siren], (*6)
Demo application using this module [https://github.com/shingo-kumagai/MyVendor.MySirenApi], (*7)
You can specify this optional value with @SirenClass
annotation., (*8)
@SirenClass("order")
Properties are the response body of the resource object., (*9)
Add sub related resource entities using @SirenEmbedResource
annotation., (*10)
@SirenEmbedResource(rel="customer", src="app://self/customer?customerId={customerId}")
And then, you can embed the entity by request like below., (*11)
$this['customer']->addQuery(['customerId' => $customerId])->eager->request();
For sub related link entity use @SirenEmbedLink
annotation., (*12)
@SirenEmbedLink(rel="order-items", src="app://self/order/items?orderNumber={orderNumber}")
Action can be added using @SirenAction
annotation., (*13)
@SirenAction(src="app://self/order/items?orderNumber={orderNumber}", method="post")
The actual method defined as SirenAction
has to be annotated like below., (*14)
/** * @SirenName("add-item") * @SirenTitle("Add Item") * @SirenField(name="orderNumber", type="hidden", value="{orderNumber}") * @SirenField(name="productCode", type="text") * @SirenField(name="quantity", type="number") * * @param int $customerId * @return $this */ public function onPost($customerId) { // do something... return $this; }
You need to define action name using @SirenName
annotation when you want to represent Action
, (*15)
This is optional. You can specify with @SirenTitle
annotation., (*16)
This is going to be controls of the action.
You can add user control for the action with @SirenField
annotation., (*17)
WIP, (*18)
@SirenLink(rel="previous", param="orderNumber") @SirenLink(rel="next", param="orderNumber")
{ "class": [ "order" ], "properties": { "orderNumber": 42, "itemCount": 3, "status": "pending" }, "entities": [ { "href": "/customer?customerId=pj123", "rel": [ "customer" ], "class": [ "info", "customer" ], "properties": { "customerId": "pj123", "name": "Peter Joseph" } }, { "href": "/orderitems?orderNumber=42", "rel": [ "order-items" ], "class": [ "items", "collection" ] } ], "actions": [ { "name": "add-item", "href": "/orderitems?orderNumber=42", "method": "POST", "title": "Add Item", "type": "application/x-www-form-urlencoded", "fields": [ { "name": "orderNumber", "type": "hidden", "value": "42" }, { "name": "productCode", "type": "text" }, { "name": "quantity", "type": "number" } ] } ], "links": [ { "rel": [ "self" ], "href": "/orders?orderNumber=42" }, { "rel": [ "previous" ], "href": "/orders?orderNumber=41" }, { "rel": [ "next" ], "href": "/orders?orderNumber=43" } ] }
MIT
MIT