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
7a37bbf1
Commit
7a37bbf1
authored
Jul 25, 2011
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
w
parent
32f27c88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
29 deletions
+66
-29
Module.php
framework/base/Module.php
+56
-27
todo.txt
todo.txt
+10
-2
No files found.
framework/base/Module.php
View file @
7a37bbf1
...
@@ -21,10 +21,6 @@ namespace yii\base;
...
@@ -21,10 +21,6 @@ namespace yii\base;
abstract
class
Module
extends
Component
abstract
class
Module
extends
Component
{
{
/**
/**
* @var string the ID of this module. This should follow the same rule as naming PHP variables.
*/
public
$id
;
/**
* @var array custom module parameters (name => value).
* @var array custom module parameters (name => value).
*/
*/
public
$params
=
array
();
public
$params
=
array
();
...
@@ -39,6 +35,7 @@ abstract class Module extends Component
...
@@ -39,6 +35,7 @@ abstract class Module extends Component
*/
*/
public
$behaviors
=
array
();
public
$behaviors
=
array
();
private
$_id
;
private
$_parentModule
;
private
$_parentModule
;
private
$_basePath
;
private
$_basePath
;
private
$_modulePath
;
private
$_modulePath
;
...
@@ -89,10 +86,12 @@ abstract class Module extends Component
...
@@ -89,10 +86,12 @@ abstract class Module extends Component
*/
*/
public
function
__get
(
$name
)
public
function
__get
(
$name
)
{
{
if
(
$this
->
hasComponent
(
$name
))
if
(
$this
->
hasComponent
(
$name
))
{
return
$this
->
getComponent
(
$name
);
return
$this
->
getComponent
(
$name
);
else
}
else
{
return
parent
::
__get
(
$name
);
return
parent
::
__get
(
$name
);
}
}
}
/**
/**
...
@@ -104,10 +103,43 @@ abstract class Module extends Component
...
@@ -104,10 +103,43 @@ abstract class Module extends Component
*/
*/
public
function
__isset
(
$name
)
public
function
__isset
(
$name
)
{
{
if
(
$this
->
hasComponent
(
$name
))
if
(
$this
->
hasComponent
(
$name
))
{
return
$this
->
getComponent
(
$name
)
!==
null
;
return
$this
->
getComponent
(
$name
)
!==
null
;
else
}
else
{
return
parent
::
__isset
(
$name
);
return
parent
::
__isset
(
$name
);
}
}
/**
* Returns a list of behaviors that this model should behave as.
* The return value of this method should be an array of behavior configurations
* indexed by behavior names. For more details, please refer to [[Model::behaviors]].
*
* The declared behaviors will be attached to the module when [[init]] is called.
* @return array the behavior configurations.
*/
public
function
behaviors
()
{
return
array
();
}
/**
* Returns the module ID.
* @return string the module ID.
*/
public
function
getId
()
{
return
$this
->
_id
;
}
/**
* Sets the module ID.
* @param string $id the module ID
*/
public
function
setId
(
$id
)
{
$this
->
_id
=
$id
;
}
}
/**
/**
...
@@ -175,27 +207,24 @@ abstract class Module extends Component
...
@@ -175,27 +207,24 @@ abstract class Module extends Component
}
}
/**
/**
* Defines the root aliases.
* Defines path aliases.
* @param array $mappings list of aliases to be defined. The array keys are root aliases,
* This method calls [[\Yii::setPathOfAlias]] to register the path aliases.
* while the array values are paths or aliases corresponding to the root aliases.
* This method is provided so that you can define path aliases by module configuration.
* @param array $aliases list of path aliases to be defined. The array keys are alias names
* (must start with '@') while the array values are the corresponding paths or aliases.
* For example,
* For example,
* <pre>
*
* ~~~
* array(
* array(
* 'models'=>'application.models', // an existing alias
* '@models' => '@app/models', // an existing alias
* 'extensions'=>'application.extensions', // an existing alias
* '@backend' => __DIR__ . '/../backend', // a directory
* 'backend'=>dirname(__FILE__).'/../backend', // a directory
* )
* )
* </pre>
* ~~~
* @since 1.0.5
*/
*/
public
function
setAliases
(
$
mapping
s
)
public
function
setAliases
(
$
aliase
s
)
{
{
foreach
(
$mappings
as
$name
=>
$alias
)
foreach
(
$aliases
as
$name
=>
$alias
)
{
{
\Yii
::
setAlias
(
$name
,
$alias
);
if
((
$path
=
Yii
::
getPathOfAlias
(
$alias
))
!==
false
)
Yii
::
setPathOfAlias
(
$name
,
$path
);
else
Yii
::
setPathOfAlias
(
$name
,
$alias
);
}
}
}
}
...
@@ -436,7 +465,7 @@ abstract class Module extends Component
...
@@ -436,7 +465,7 @@ abstract class Module extends Component
/**
/**
* Loads static application components.
* Loads static application components.
*/
*/
p
rotected
function
preloadComponents
()
p
ublic
function
preloadComponents
()
{
{
foreach
(
$this
->
preload
as
$id
)
foreach
(
$this
->
preload
as
$id
)
$this
->
getComponent
(
$id
);
$this
->
getComponent
(
$id
);
...
@@ -449,7 +478,7 @@ abstract class Module extends Component
...
@@ -449,7 +478,7 @@ abstract class Module extends Component
* Note that at this moment, the module is not configured yet.
* Note that at this moment, the module is not configured yet.
* @see init
* @see init
*/
*/
p
rotected
function
preinit
()
p
ublic
function
preinit
()
{
{
}
}
...
@@ -460,7 +489,7 @@ abstract class Module extends Component
...
@@ -460,7 +489,7 @@ abstract class Module extends Component
* have been attached and the application components have been registered.
* have been attached and the application components have been registered.
* @see preinit
* @see preinit
*/
*/
p
rotected
function
init
()
p
ublic
function
init
()
{
{
}
}
}
}
todo.txt
View file @
7a37bbf1
- CompareValidator::clientValidateAttribute(): search for "CHtml::activeId"
- CompareValidator::clientValidateAttribute(): search for "CHtml::activeId"
- FileValidator, UniqueValidator, ExistValidator, DateValidator: TBD
- FileValidator, UniqueValidator, ExistValidator, DateValidator: TBD
- Can consider merging UniqueValidator and ExistValidator and using a NOT property.
- Can consider merging UniqueValidator and ExistValidator and using a NOT property.
\ No newline at end of file
- design of component life cycles: init() and afterConstruct()
* construct object
* preinit
* attachBehaviors
* initialize properties
* init
* ...
* destruct
\ No newline at end of file
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