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
710e70b8
Commit
710e70b8
authored
Oct 02, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2037: Dropped the support for using `yii\base\Module` as concrete module classes
parent
161e3ab3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
structure-modules.md
docs/guide/structure-modules.md
+6
-2
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Module.php
framework/base/Module.php
+0
-3
No files found.
docs/guide/structure-modules.md
View file @
710e70b8
...
@@ -29,7 +29,7 @@ forum/
...
@@ -29,7 +29,7 @@ forum/
### Module Classes <a name="module-classes"></a>
### Module Classes <a name="module-classes"></a>
Each module should have a module class which extends from
[
[yii\base\Module
]
]. The class should be located
Each module should have a
unique
module class which extends from
[
[yii\base\Module
]
]. The class should be located
directly under the module's
[
[yii\base\Module::basePath|base path
]
] and should be
[
autoloadable
](
concept-autoloading.md
)
.
directly under the module's
[
[yii\base\Module::basePath|base path
]
] and should be
[
autoloadable
](
concept-autoloading.md
)
.
When a module is being accessed, a single instance of the corresponding module class will be created.
When a module is being accessed, a single instance of the corresponding module class will be created.
Like
[
application instances
](
structure-applications.md
)
, module instances are used to share data and components
Like
[
application instances
](
structure-applications.md
)
, module instances are used to share data and components
...
@@ -173,7 +173,7 @@ different from the one created by Yii in response to a request.
...
@@ -173,7 +173,7 @@ different from the one created by Yii in response to a request.
You may also access the instance of a module using the following approaches:
You may also access the instance of a module using the following approaches:
```
php
```
php
// get the module whose ID is "forum"
// get the
child
module whose ID is "forum"
$module
=
\Yii
::
$app
->
getModule
(
'forum'
);
$module
=
\Yii
::
$app
->
getModule
(
'forum'
);
// get the module to which the currently requested controller belongs
// get the module to which the currently requested controller belongs
...
@@ -239,6 +239,10 @@ For a controller within a nested module, its route should include the IDs of all
...
@@ -239,6 +239,10 @@ For a controller within a nested module, its route should include the IDs of all
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.
> Info: The [[yii\base\Module::getModule()|getModule()]] method only returns the child module directly belonging
to its parent. The
[
[yii\base\Application::loadedModules
]
] property keeps a list of loaded modules, including both
direct children and nested ones, indexed by their class names.
## Best Practices <a name="best-practices"></a>
## Best Practices <a name="best-practices"></a>
...
...
framework/CHANGELOG.md
View file @
710e70b8
...
@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
...
@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
-
Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe)
-
Bug: Date and time formatting now assumes UTC as the timezone for input dates unless a timezone is explicitly given (cebe)
-
Enh #4275: Added
`removeChildren()`
to
`yii\rbac\ManagerInterface`
and implementations (samdark)
-
Enh #4275: Added
`removeChildren()`
to
`yii\rbac\ManagerInterface`
and implementations (samdark)
-
Enh: Added
`yii\base\Application::loadedModules`
(qiangxue)
-
Enh: Added
`yii\base\Application::loadedModules`
(qiangxue)
-
Chg #2037: Dropped the support for using
`yii\base\Module`
as concrete module classes (qiangxue)
2.0.0-rc September 27, 2014
2.0.0-rc September 27, 2014
...
...
framework/base/Module.php
View file @
710e70b8
...
@@ -350,9 +350,6 @@ class Module extends ServiceLocator
...
@@ -350,9 +350,6 @@ class Module extends ServiceLocator
return
$this
->
_modules
[
$id
];
return
$this
->
_modules
[
$id
];
}
elseif
(
$load
)
{
}
elseif
(
$load
)
{
Yii
::
trace
(
"Loading module:
$id
"
,
__METHOD__
);
Yii
::
trace
(
"Loading module:
$id
"
,
__METHOD__
);
if
(
is_array
(
$this
->
_modules
[
$id
])
&&
!
isset
(
$this
->
_modules
[
$id
][
'class'
]))
{
$this
->
_modules
[
$id
][
'class'
]
=
'yii\base\Module'
;
}
/* @var $module Module */
/* @var $module Module */
$module
=
Yii
::
createObject
(
$this
->
_modules
[
$id
],
[
$id
,
$this
]);
$module
=
Yii
::
createObject
(
$this
->
_modules
[
$id
],
[
$id
,
$this
]);
$module
->
setInstance
(
$module
);
$module
->
setInstance
(
$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