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
b7630c00
Commit
b7630c00
authored
Nov 19, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6117 from cdvrooman/patch-1
Update structure-modules.md
parents
704aa566
50a56ad2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
structure-modules.md
docs/guide/structure-modules.md
+5
-5
No files found.
docs/guide/structure-modules.md
View file @
b7630c00
...
@@ -100,7 +100,7 @@ class PostController extends Controller
...
@@ -100,7 +100,7 @@ class PostController extends Controller
```
```
You may customize the namespace of controller classes by configuring the
[
[yii\base\Module::controllerNamespace
]
]
You may customize the namespace of controller classes by configuring the
[
[yii\base\Module::controllerNamespace
]
]
property. In case
when some of the controllers are out
of this namespace, you may make them accessible
property. In case
some of the controllers are outside
of this namespace, you may make them accessible
by configuring the
[
[yii\base\Module::controllerMap
]
] property, similar to
[
what you do in an application
](
structure-applications.md#controller-map
)
.
by configuring the
[
[yii\base\Module::controllerMap
]
] property, similar to
[
what you do in an application
](
structure-applications.md#controller-map
)
.
...
@@ -162,7 +162,7 @@ $module = MyModuleClass::getInstance();
...
@@ -162,7 +162,7 @@ $module = MyModuleClass::getInstance();
where
`MyModuleClass`
refers to the name of the module class that you are interested in. The
`getInstance()`
method
where
`MyModuleClass`
refers to the name of the module class that you are interested in. The
`getInstance()`
method
will return the currently requested instance of the module class. If the module is not requested, the method will
will return the currently requested instance of the module class. If the module is not requested, the method will
return null. Note that
Y
ou do not want to manually create a new instance of the module class because it will be
return null. Note that
y
ou do not want to manually create a new instance of the module class because it will be
different from the one created by Yii in response to a request.
different from the one created by Yii in response to a request.
> Info: When developing a module, you should not assume the module will use a fixed ID. This is because a module
> Info: When developing a module, you should not assume the module will use a fixed ID. This is because a module
...
@@ -183,7 +183,7 @@ $module = \Yii::$app->controller->module;
...
@@ -183,7 +183,7 @@ $module = \Yii::$app->controller->module;
The first approach is only useful when you know the module ID, while the second approach is best used when you
The first approach is only useful when you know the module ID, while the second approach is best used when you
know about the controllers being requested.
know about the controllers being requested.
Once
getting hold of a module instance, you can access parameters or
components registered with the module. For example,
Once
you have the module instance, you can access parameters and
components registered with the module. For example,
```
php
```
php
$maxPostCount
=
$module
->
params
[
'maxPostCount'
];
$maxPostCount
=
$module
->
params
[
'maxPostCount'
];
...
@@ -195,7 +195,7 @@ $maxPostCount = $module->params['maxPostCount'];
...
@@ -195,7 +195,7 @@ $maxPostCount = $module->params['maxPostCount'];
Some modules may need to be run for every request. The
[
[yii\debug\Module|debug
]
] module is such an example.
Some modules may need to be run for every request. The
[
[yii\debug\Module|debug
]
] module is such an example.
To do so, list the IDs of such modules in the
[
[yii\base\Application::bootstrap|bootstrap
]
] property of the application.
To do so, list the IDs of such modules in the
[
[yii\base\Application::bootstrap|bootstrap
]
] property of the application.
For example, the following application configuration makes sure the
`debug`
module is always load:
For example, the following application configuration makes sure the
`debug`
module is always load
ed
:
```
php
```
php
[
[
...
@@ -235,7 +235,7 @@ class Module extends \yii\base\Module
...
@@ -235,7 +235,7 @@ class Module extends \yii\base\Module
}
}
```
```
For a controller within a nested module, its route should include the IDs of all its ancestor module.
For a controller within a nested module, its route should include the IDs of all its ancestor module
s
.
For example, the route
`forum/admin/dashboard/index`
represents the
`index`
action of the
`dashboard`
controller
For example, the route
`forum/admin/dashboard/index`
represents the
`index`
action of the
`dashboard`
controller
in the
`admin`
module which is a child module of the
`forum`
module.
in the
`admin`
module which is a child module of the
`forum`
module.
...
...
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