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
bdee46d1
Commit
bdee46d1
authored
Jan 26, 2015
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7019 from softark/docs-guide-structure-fix
Docs guide structure fix [ci skip]
parents
36bebbfe
b227eff4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
structure-applications.md
docs/guide/structure-applications.md
+1
-1
structure-controllers.md
docs/guide/structure-controllers.md
+5
-7
No files found.
docs/guide/structure-applications.md
View file @
bdee46d1
...
@@ -505,7 +505,7 @@ handlers to these events in application configurations like the following,
...
@@ -505,7 +505,7 @@ handlers to these events in application configurations like the following,
The use of the `on eventName` syntax is described in the [Configurations](concept-configurations.md#configuration-format)
The use of the `on eventName` syntax is described in the [Configurations](concept-configurations.md#configuration-format)
section.
section.
Alternatively, you may attach event handlers during the [bootstrapping process](runtime-bootstrapping.md)
process
Alternatively, you may attach event handlers during the [bootstrapping process](runtime-bootstrapping.md)
after the application instance is created. For example,
after the application instance is created. For example,
```
php
```
php
...
...
docs/guide/structure-controllers.md
View file @
bdee46d1
...
@@ -10,7 +10,7 @@ into [views](structure-views.md), and finally generate outgoing responses.
...
@@ -10,7 +10,7 @@ into [views](structure-views.md), and finally generate outgoing responses.
## Actions <span id="actions"></span>
## Actions <span id="actions"></span>
Controllers are composed
by
*actions*
which are the most basic units that end users can address and request for
Controllers are composed
of
*actions*
which are the most basic units that end users can address and request for
execution. A controller can have one or multiple actions.
execution. A controller can have one or multiple actions.
The following example shows a
`post`
controller with two actions:
`view`
and
`create`
:
The following example shows a
`post`
controller with two actions:
`view`
and
`create`
:
...
@@ -153,7 +153,7 @@ in `@app/controllers/admin/Post2CommentController.php`.
...
@@ -153,7 +153,7 @@ in `@app/controllers/admin/Post2CommentController.php`.
You can configure
[
[yii\base\Application::controllerMap|controller map
]
] to overcome the constraints
You can configure
[
[yii\base\Application::controllerMap|controller map
]
] to overcome the constraints
of the controller IDs and class names described above. This is mainly useful when you are using some
of the controller IDs and class names described above. This is mainly useful when you are using some
third-party controllers which you do not control over their class names.
third-party controllers which you do not
have
control over their class names.
You may configure
[
[yii\base\Application::controllerMap|controller map
]
] in the
You may configure
[
[yii\base\Application::controllerMap|controller map
]
] in the
[
application configuration
](
structure-applications.md#application-configurations
)
like the following:
[
application configuration
](
structure-applications.md#application-configurations
)
like the following:
...
@@ -177,7 +177,7 @@ You may configure [[yii\base\Application::controllerMap|controller map]] in the
...
@@ -177,7 +177,7 @@ You may configure [[yii\base\Application::controllerMap|controller map]] in the
### Default Controller <span id="default-controller"></span>
### Default Controller <span id="default-controller"></span>
Each application has a default controller specified via the
[
[yii\base\Application::defaultRoute
]
] property.
Each application has a default controller specified via the
[
[yii\base\Application::defaultRoute
]
] property.
When a request does not specify a
[
route
](
#
ids-
routes
)
, the route specified by this property will be used.
When a request does not specify a
[
route
](
#routes
)
, the route specified by this property will be used.
For
[
[yii\web\Application|Web applications
]
], its value is
`'site'`
, while for
[
[yii\console\Application|console applications
]
],
For
[
[yii\web\Application|Web applications
]
], its value is
`'site'`
, while for
[
[yii\console\Application|console applications
]
],
it is
`help`
. Therefore, if a URL is
`http://hostname/index.php`
, it means the
`site`
controller will handle the request.
it is
`help`
. Therefore, if a URL is
`http://hostname/index.php`
, it means the
`site`
controller will handle the request.
...
@@ -284,7 +284,6 @@ As you can see, the `actions()` method should return an array whose keys are act
...
@@ -284,7 +284,6 @@ As you can see, the `actions()` method should return an array whose keys are act
action class names or
[
configurations
](
concept-configurations.md
)
. Unlike inline actions, action IDs for standalone
action class names or
[
configurations
](
concept-configurations.md
)
. Unlike inline actions, action IDs for standalone
actions can contain arbitrary characters, as long as they are declared in the
`actions()`
method.
actions can contain arbitrary characters, as long as they are declared in the
`actions()`
method.
To create a standalone action class, you should extend
[
[yii\base\Action
]
] or its child class, and implement
To create a standalone action class, you should extend
[
[yii\base\Action
]
] or its child class, and implement
a public method named
`run()`
. The role of the
`run()`
method is similar to that of an action method. For example,
a public method named
`run()`
. The role of the
`run()`
method is similar to that of an action method. For example,
...
@@ -309,8 +308,7 @@ class HelloWorldAction extends Action
...
@@ -309,8 +308,7 @@ class HelloWorldAction extends Action
The return value of an action method or the
`run()`
method of a standalone action is significant. It stands
The return value of an action method or the
`run()`
method of a standalone action is significant. It stands
for the result of the corresponding action.
for the result of the corresponding action.
The return value can be a
[
response
](
runtime-responses.md
)
object which will be sent to as the response
The return value can be a
[
response
](
runtime-responses.md
)
object which will be sent to the end user as the response.
to end users.
*
For
[
[yii\web\Application|Web applications
]
], the return value can also be some arbitrary data which will
*
For
[
[yii\web\Application|Web applications
]
], the return value can also be some arbitrary data which will
be assigned to
[
[yii\web\Response::data
]
] and be further converted into a string representing the response body.
be assigned to
[
[yii\web\Response::data
]
] and be further converted into a string representing the response body.
...
@@ -385,7 +383,7 @@ please refer to the [Console Commands](tutorial-console.md) section for more det
...
@@ -385,7 +383,7 @@ please refer to the [Console Commands](tutorial-console.md) section for more det
### Default Action <span id="default-action"></span>
### Default Action <span id="default-action"></span>
Each controller has a default action specified via the
[
[yii\base\Controller::defaultAction
]
] property.
Each controller has a default action specified via the
[
[yii\base\Controller::defaultAction
]
] property.
When a
[
route
](
#
ids-
routes
)
contains the controller ID only, it implies that the default action of
When a
[
route
](
#routes
)
contains the controller ID only, it implies that the default action of
the specified controller is requested.
the specified controller is requested.
By default, the default action is set as
`index`
. If you want to change the default value, simply override
By default, the default action is set as
`index`
. If you want to change the default value, simply override
...
...
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