-
Notifications
You must be signed in to change notification settings - Fork 32
REST write support #93
Comments
@lsmith77 you did some tweaking, right? what is still missing? |
we have read support now .. but no write support |
maybe this is better delegated to SyliusResourceBundle or we extend it for our needs. need a bit of work however on some details however: |
i agree, this should not be specific to the content bundle. note that CmfCreateBundle also has a generic write handler, for json-ld, and tied to the createphp mapping rules. |
another possibility http://stanlemon.net/2014/10/07/demoing-lemonrestbundle-with-ng-admin/ |
@lsmith77 You have got some more ideas with that issue? Would like to work on it on our slacktime day on friday. |
not really .. basically the controller will need to get some more methods for POST (adding a new page), PUT (updating a page) and DELETE (deleting a page). Note that a page obviously consists of 1) a route and 2) a content document (with references and children). I think for a DELETE it should be possible to only delete the route and not the content. Either way both the route and the content can have children, especially in this case we might have to do some cleanups to ensure we do not end up with routes that point to non existent content. Maybe eventually we also want to support some modes for DELETE where for example the node is not deleted if there are children, but instead just the data in the node is removed. But this is all future stuff .. |
In generall controller would extend or replace the existing What about access? OPTION should answer some allowed methods i think. |
we could look into moving some logic to a helper yes .. but imho that is a 2nd step. until then people can also extend the default controller to add functionality of needed. |
something like https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/ResourceBundle/Controller/DomainManager.php could be useful here .. maybe this can be "unbundled" from ResourceBundle |
ok, had a look at their ResourceController too. Would do same, but without their container injection. :-) |
maybe .. my main point was that it could be useful to have a separate class to handle the actual interaction with the EM/DM |
just from the name and idea, this reminds me of https://github.com/sonata-project/SonataAdminBundle/blob/master/Model/ModelManagerInterface.php which is the sonata bridge thing to abstract from doctrine. i guess extracting something like this into a standalone thing could be useful. sonata is doing way too much for us (its aimed at the admin lists and similar things, with paging and whatnot) while the sylius one seems rather limited (e.g. the "move" is some undocumented numeric value that seems to be added to the relative position of a model). i am not sure if it makes sense to share this abstraction with sylius or sonata, or if its better we do our own that can do the operations that we need. our own would duplicate some logic, but extracting some other thing could be a major undertaking and we would need a common agreement on what is needed. it does sound like a useful endavour, but could be changed as a version 2. |
I am back on that issue again and still have some questions. Please just correct me.
|
those semantics sound right to me.
i wonder how this should or should not interact with ResourceRestBundle
and/or RoutingAutoBundle? though RoutingAuto is different - here we
would have the desired URL and don't need any guesser to figure out the
URL, only the correct document class.
how do you know what type of content document to create here? is the
client supposed to send that in meta data? CreateBundle is doing
something similar already with the json-ld data and a mapping from types
to document classes.
i think such mappings and similar logic sounds like it should be in
ResourceRestBundle.
|
there is a big difference with ContentBundle uses the routing to find documents, while ResourceBundle goes directly to the content structure. |
Yea exactly @lsmith and so the the ContentBundle's REST API would be the right endpiont for native Frontend editing as a user would like to edit content where they find it in routing. The API build by ResourcesRestBundle would be a nice endpoint for an Client side admin application. (Example) |
okay. makes sense. i am just a bit afraid of ending up with 4 partly
working editing solutions (sonata, create, resource rest, content rest)
|
@dbu I see create = content rest or as an replacement for the |
@lsmith77 & @dbu i still have some problems thinking on the routing: 1.) enabling other actions on routes the dynamic router knows, like PUT & DELETE PUT would mean there must be a known content document, so it would be like |
Won't adding ContentBundle REST support mean doing CreatePHP without RDFa, meaning a less generic solution than the current state? Create stuff is a bit unmaintained (I've plans for revamping the CmfCreateBundle btw), so we may have to create a new library that replaces the Create packages. However, I think we should still use some kind of RDFa mapping or the like. Don't forget that the documents in this bundle are just meant as a base and almost every application will extend them. Btw, for the route generation, I think using RoutingAuto and it's multi route support would be a good solution. |
@wouterj simply no :-) I think we can't remove the RDFa. We do need them for the Frontend editing. So they should come with some metadata or on an specific api in the
|
i am not sure how much we can reverse the routing information. we have content class to controller mappings. this can not easily be reversed as there could be several classes going to the same controller. we could kindof build a similar thing but for POST, where a map of class to controller tells which creator method to use. but i think wouter is correct that this is redoing what RestBundle is supposed to do, and what CreateBundle already does. i think the only thing not covered in the current RestBundle / CreateBundle discussions is how the front-end can define the target URL (aka route) of a new content. but i am not sure if it makes sense to have a third option besides a REST api that allows to create the route and then create the document, and the routing auto bundle that allows to autogenerate the route. |
So ... I think i would have a first suggestion: RestBundle The ideas are:
Note: |
i don't want to be negative, but is that RestBundle doing anything that FOSRestBundle does not offer? i think i would rather follow this approach:
|
Yea it was my fault. Did the comment on the wrong issue. @dbu you are right, yes. But only on a half way. FOSRest should do the work for the ContententBundle. I would suggest a so called Doing so we would keep the responsibilities in each bundle low. It would be a bad idea to implement routing stuff inside the ContentBundle. |
REST routes are directly related to a Controller, right? So those routes are as static as they can get, aren't they? I fail to see the exact benefit of using the dynamic router here. |
@wouterj for the ContentBundle we wanna have routes which are exactly the same routes as the content is currently available on GET. Example: What we whant for ContentBundle's REST functions are routes like:
For 1-3 the dynamic router will do the work as it does it now, it just matches the route, adds the content. But we do not have any controller_by_method enhancer to get a specific action and the new Bundle would simply add a method aware enhancer (and i still have one of those enhancers in the bundle working) Note: |
I don't think we need an extra bundle for this:
Just like @dbu, I don't want to be too negative, but we're a very small team. I don't think we should maintain many different ways of doing the same thing. We already maintain CreatePHP, ResourceRest and Admin, also maintaining yet another way of editing documents which is quite similar to what ResourceRest will look like in the future seems to be not worth it imo. |
@wouterj i wouldn't be that sad, when copying that code into |
the controller_by_method enhancer sounds like a good idea to me and could cover most of what you propose with little extra code. |
indeed, that's is really a small amount of code. So we could at that to But:
Btw 1.0: i do not wanna fight for an extra bundle, just want to point on Btw 2.0: we should do the architectural discussions in the |
I am not too deep in this thread, but I thought I would just mention RoutingAuto here. You will soon be able to generate multiple routes for each Entity/Document. So this would enable you to generate not only the front-end route, but also backend routes if required. Each of which can have a |
with #91 and schmittjoh/serializer#184 REST read support is basically available.
however it would be cool to get some more sane defaults for the response and/or more aspects that can be configured globally without having to map it out for each class. furthermore we need some handling for relations so that they can optionally just be referenced by url/id rather then be inlined.
The text was updated successfully, but these errors were encountered: