Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b079c73a
Commit
b079c73a
authored
Dec 29, 2013
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs about response
parent
f3450682
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
controller.md
docs/guide/controller.md
+23
-1
No files found.
docs/guide/controller.md
View file @
b079c73a
...
@@ -35,7 +35,29 @@ class SiteController extends Controller
...
@@ -35,7 +35,29 @@ class SiteController extends Controller
```
```
As you can see, typical controller contains actions that are public class methods named as
`actionSomething`
.
As you can see, typical controller contains actions that are public class methods named as
`actionSomething`
.
The output of an action is what the method returns. The return value will be handled by the
`response`
application
The output of an action is what the method returns, it could be rendered result or it can be instance of
```yii\web\Response```
, for example:
```
php
namespace
app\controllers
;
use
yii\web\Controller
;
use
app\components\web\MyCustomResponse
;
#extended from yii\web\Response
class
SiteController
extends
Controller
{
public
function
actionCustom
()
{
/*
* do your things here
* since Response in extended from yii\base\Object, you can initialize its values by passing in
* __constructor() simple array.
*/
return
new
MyCustomResponse
([
'data'
=>
$myCustomData
]);
}
}
```
The return value will be handled by the
`response`
application
component which can convert the output to differnet formats such as JSON for example. The default behavior
component which can convert the output to differnet formats such as JSON for example. The default behavior
is to output the value unchanged though.
is to output the value unchanged though.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment