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
8aee4759
Commit
8aee4759
authored
Jun 02, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
f7bc1060
fc28cee5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
structure-controllers.md
docs/guide/structure-controllers.md
+12
-7
No files found.
docs/guide/structure-controllers.md
View file @
8aee4759
...
@@ -408,7 +408,7 @@ class PostController extends Controller
...
@@ -408,7 +408,7 @@ class PostController extends Controller
if
(
$model
!==
null
)
{
if
(
$model
!==
null
)
{
return
$this
->
render
(
'view'
,
[
return
$this
->
render
(
'view'
,
[
'model'
=>
$model
s
,
'model'
=>
$model
,
]);
]);
}
else
{
}
else
{
throw
new
NotFoundHttpException
;
throw
new
NotFoundHttpException
;
...
@@ -435,10 +435,15 @@ is loaded successfully, it will display it using the view named `view`. Otherwis
...
@@ -435,10 +435,15 @@ is loaded successfully, it will display it using the view named `view`. Otherwis
In the
`create`
action, the code is similar. It first tries to populate the model using the request data
In the
`create`
action, the code is similar. It first tries to populate the model using the request data
and save the model. If both succeed it will redirect the browser to the
`view`
action with the ID of
and save the model. If both succeed it will redirect the browser to the
`view`
action with the ID of
the newly model. Otherwise it will display the
`create`
view through which users can provide the needed input.
the newly created model. Otherwise it will display the
`create`
view through which users can provide the needed input.
In summary, a controller
*
may access the
[
request
](
runtime-requests.md
)
data;
*
may send commands to
[
models
](
structure-models.md
)
and
[
views
](
structure-views.md
)
;
*
should return the
[
response
](
runtime-responses.md
)
data;
*
should NOT process the request data;
*
should NOT build the response data.
In summary, the code in a controller may access the
[
request
](
runtime-requests.md
)
and
[
response
](
runtime-responses.md
)
If your controller is rather complicated, it usually indicates that you should refactor it and move some code
objects,
[
models
](
structure-models.md
)
and
[
views
](
structure-views.md
)
. It should not, however, try to
to other classes.
process the request data or build up response result - those are the jobs of
[
models
](
structure-models.md
)
and
[
views
](
structure-views.md
)
. If your controller is rather complicated, it is usually an indication that
you should refactor your controller code.
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