Emulating REST collection/resource with Datasources
This is an open discussion with 5 replies, filed under General.
Search
If you don't want your ingredients datasource to load you can do one the following:
a) drop your ingredient datasource, and add the filter to the ingredients. You'll get all the ingredients on the list view and a single item in the second (no required param)
b) on the ingredients datasource set a 'forbidden' parameter. Whenever this forbidden parameter is set, the datasource will not load. The forbidden parameter would represent your resource id.
Thanks, @gunglien. I decided to go with b
. However, I have no idea on how to add a 'forbidden' parameter to a datasource. I searched a lot and didn't find a thing. Could you elaborate further, please?
Do you use Symphony 2.6? Then you will find the "Forbidden Parameter" on the DS edit page. If it's an older version of Symphony, you should consider updating.
Oh... No, I'm not using Symphony 2.6. Currently my installation uses 2.3 because there are some extensions that are not supported on 2.6 version, and I really can't get rid of them and all their data.
Symphony 2.3 does not have "Forbidden Parameter" functionality. So solution b) from above won't work.
Create an account or sign in to comment.
I have an app I want to power up using Symphony to generate the JSON needed at a certain endpoint (just like a normal REST endpoint with collection/resource style.)
My endpoint would be something like
api.foobar.com/ingredients(collection)/ingredient(resource ID)
.So far I tried creating two datasources: one for the collection named
ingredients
(this will load up all ingredients,) and a seconds one for the resource namedingredient
(this will load up a single ingredient based on an URL parameter.)I also created a page named
ingredients
and added both datasources to it. It has theid
parameter assigned to it.Everything is working, the collection loads up all the ingredients (as it should), but when I access the resource with a valid ID, it returns the collection plus the single resource. This is fine, but the loading time and the XML generation time are the same in both cases, which means I'm loading all the entries even when I access the resource endpoint, which in this case should load only one entry and not all the entries from the collection too.
Is there a way to solve this? What do you think?