i would like to know what data can be returned from the controllers in g2 and how it is evaluated. I did not find much information about this in the source code and collecting the information from the modules is quite tedious.
So it would be great if we could collect some information about this.
The controller returns an array (here: $results) with information about what view to use, and can also give some information to the view.
What i assume so far is the following:
contains flags which signal that a certain error has occured. It is used like this:
$results['error'] = 'form[error][userName][missing]'
This information is given to the template (question: on redirect and delegate?), which can check the flag via "isset($form.error.userName.missing)"
contains information about the status which resulted from the last operation. Stored as associative array and used like this:
$results['status']['modifiedUser'] = $user->getUserName();
In the template it can be accessed as $status.modifiedUser
(question: template var is only present after a redirect, not after a delegate, right?)
contains information about the view to use.
$result['delegate']['view'] is the view itself
$result['delegate']['subView'] optionally is a subview to use
(question: are there any more options to the delegate array?)
OR (only one of (delegate|redirect) can be used)
forces a http-redirect to the given view.
$result['redirect']['view'] is the view itself
$result['redirect']['subView'] optionally is a subview to use
The controller is determined by the view. Optionally it can be set explicitly by $result['redirect']['controller']='...' (which is possible in g2 urls generally)
Any other key-value-pairs in the redirect array are set as query variables in the redirect-url.
(question: are there any more options to the redirect-array?)
Am i right so far? Are there any more options to control the application flow which i have not noticed yet?
I think i saw an entry 'return' somewhere without knowing what it does...
It would be great to collect all the information about these arrays. This will certainly be a big help for other developers starting with g2.