3 ms·
Re: API endpoint, that's exactly it. Here are several equivalent ways of expressing this: // PHP $accounts = get("/accounts"); // Template {g
by ericingram 14y ago
Re: API endpoint, that's exactly it.
Here are several equivalent ways of expressing this:
// PHP
$accounts = get("/accounts");
// Template
{get $accounts from "/accounts"}
{$accounts = get("/accounts")}
{$accounts = "/accounts"|get}
Here's a really cool side effect of the way the model result works...
{$account = "/accounts/123"|get}
{put [role => "admin"] in $account}
When converted to a string, they represent a model URI.
- ricardobeat 14y ago{put [role => "admin"] in $account} Does this mean you have all your view logic inside the templates?
- ericingram 14y agoGenerally logic that is good in a controller can be put in the template file instead. This idea came from the "Smart model, Dumb controller" concept. We made controllers so dumb, it was rather clean and easy to understand when combined with a template. We see more of this with client side frameworks like Meteor. Still, Forward is built on a new micro MVC framework and controllers do still exist. Those that prefer to write them can do so in a more traditional way. class AccountController extends Controller { function index () { $this->account = get("/accounts/123"); put($this->account, [role => "admin"]); } } (This is not very useful code but you get the idea)