Howdy! I get the concept of ModelAsController to enable straight DataObjects to return data from URLs REST style without creating a formal *_Controller extends ContentController. Is this logic correct?
If so does anyone have an example of how to do this? I can see that in the Director config there is the base rule that should use the URLSegment to default an Object name to ModelAsController.
ie. http://mysssite.com/SomeObject/asdf/asdf
should trigger some use of
class SomeObject extends DataObject {
...
public function asdf() {
//Do stuff with $this->URLParams?
}
}
I can see that the docblock from ModelAsController has been pasted into the wiki: http://doc.silverstripe.com/doku.php?id=modelascontroller
I haven't had any success trying to get a model to return anything. I have tried adding such things to my model as static $URLSegment, static $allowed_actions, and function modelascontrollerInit($c){} with no luck yet. Every attempt to access http://mysssite.com/SomeObject/asdf/asdf returns a 404 Page Not Found.
Thoughts, examples, help anyone? It will be greatly appreciated and I'll be sure to update the wiki with any information provided.