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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
c1cb99ab
Commit
c1cb99ab
authored
May 05, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
controller work.
parent
cc0be8ad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
54 deletions
+45
-54
Action.php
framework/base/Action.php
+16
-11
Application.php
framework/base/Application.php
+8
-14
Controller.php
framework/base/Controller.php
+0
-0
Module.php
framework/base/Module.php
+21
-29
No files found.
framework/base/Action.php
View file @
c1cb99ab
...
...
@@ -35,21 +35,26 @@ class Action extends Component
public
$controller
;
/**
* Runs the action with the supplied parameters.
* This method is invoked by the controller.
* @param string $id the ID of this action
* @param Controller $controller the controller that owns this action
*/
public
function
__construct
(
$id
,
$controller
)
{
$this
->
id
=
$id
;
$this
->
controller
=
$controller
;
}
/**
* Normalizes the input parameters for the action.
* The parameters will later be passed to the `run()` method of the action.
* This method is mainly called by the controller when running an action.
* @param array $params the input parameters in terms of name-value pairs.
* @return
boolean whether the input parameters are valid
* @return
array|boolean the normalized parameters, or false if the input parameters are invalid.
*/
public
function
runWith
Params
(
$params
)
public
function
normalize
Params
(
$params
)
{
$method
=
new
\ReflectionMethod
(
$this
,
'run'
);
$params
=
$this
->
normalizeParamsByMethod
(
$method
,
$params
);
if
(
$params
!==
false
)
{
call_user_func_array
(
array
(
$this
,
'run'
),
$params
);
return
true
;
}
else
{
return
false
;
}
return
$this
->
normalizeParamsByMethod
(
$method
,
$params
);
}
/**
...
...
framework/base/Application.php
View file @
c1cb99ab
...
...
@@ -89,6 +89,11 @@ class Application extends Module
* @see language
*/
public
$sourceLanguage
=
'en_us'
;
/**
* @var array IDs of application components that need to be loaded when the application starts.
* The default value is `array('errorHandler')`, which loads the [[errorHandler]] component
* to ensure errors and exceptions can be handled nicely.
*/
public
$preload
=
array
(
'errorHandler'
);
public
$localeDataPath
=
'@yii/i18n/data'
;
...
...
@@ -99,12 +104,14 @@ class Application extends Module
/**
* Constructor.
* @param string $id the ID of this application. The ID should uniquely identify the application from others.
* @param string $basePath the base path of this application. This should point to
* the directory containing all application logic, template and data.
*/
public
function
__construct
(
$basePath
)
public
function
__construct
(
$
id
,
$
basePath
)
{
\Yii
::
$application
=
$this
;
$this
->
id
=
$id
;
$this
->
setBasePath
(
$basePath
);
\Yii
::
setAlias
(
'application'
,
$this
->
getBasePath
());
$this
->
registerCoreComponents
();
...
...
@@ -177,19 +184,6 @@ class Application extends Module
}
/**
* Returns the unique identifier for the application.
* @return string the unique identifier for the application.
*/
public
function
getId
()
{
if
((
$id
=
parent
::
getId
())
===
null
)
{
$id
=
sprintf
(
'%x'
,
crc32
(
$this
->
getBasePath
()
.
$this
->
name
));
$this
->
setId
(
$id
);
}
return
$id
;
}
/**
* Returns the directory that stores runtime files.
* @return string the directory that stores runtime files. Defaults to 'protected/runtime'.
*/
...
...
framework/base/Controller.php
View file @
c1cb99ab
This diff is collapsed.
Click to expand it.
framework/base/Module.php
View file @
c1cb99ab
...
...
@@ -14,9 +14,9 @@ namespace yii\base;
*
* Module mainly manages application components and sub-modules that belongs to a module.
*
* @property string $id The module ID.
* @property string $uniqueId An ID that uniquely identifies this module among all modules within
* the current application.
* @property string $basePath The root directory of the module. Defaults to the directory containing the module class.
* @property Module|null $parentModule The parent module. Null if this module does not have a parent.
* @property array $modules The configuration of the currently installed modules (module ID => configuration).
* @property array $components The application components (indexed by their IDs).
* @property array $import List of aliases to be imported. This property is write-only.
...
...
@@ -35,10 +35,16 @@ abstract class Module extends Component implements Initable
* @var array the IDs of the application components that should be preloaded when this module is created.
*/
public
$preload
=
array
();
/**
* @var string an ID that uniquely identifies this module among other modules which have the same [[parent]].
*/
public
$id
;
/**
* @var Module the parent module of this module. Null if this module does not have a parent.
*/
public
$module
;
private
$_id
;
private
$_basePath
;
private
$_parentModule
;
private
$_modules
=
array
();
private
$_components
=
array
();
...
...
@@ -49,8 +55,8 @@ abstract class Module extends Component implements Initable
*/
public
function
__construct
(
$id
,
$parent
=
null
)
{
$this
->
_
id
=
$id
;
$this
->
_parentM
odule
=
$parent
;
$this
->
id
=
$id
;
$this
->
m
odule
=
$parent
;
}
/**
...
...
@@ -93,26 +99,21 @@ abstract class Module extends Component implements Initable
*/
public
function
init
()
{
\Yii
::
setAlias
(
'@'
.
$this
->
getId
()
,
$this
->
getBasePath
());
\Yii
::
setAlias
(
'@'
.
$this
->
id
,
$this
->
getBasePath
());
$this
->
preloadComponents
();
}
/**
* 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
* Returns an ID that uniquely identifies this module among all modules within the current application.
* @return string the unique ID of the module.
*/
public
function
setId
(
$id
)
public
function
getUniqueId
(
)
{
$this
->
_id
=
$id
;
if
(
$this
->
module
&&
!
$this
->
module
instanceof
Application
)
{
return
$this
->
module
->
getUniqueId
()
.
"/
{
$this
->
id
}
"
;
}
else
{
return
$this
->
id
;
}
}
/**
...
...
@@ -180,15 +181,6 @@ abstract class Module extends Component implements Initable
}
/**
* Returns the parent module.
* @return Module|null the parent module. Null is returned if this module does not have a parent.
*/
public
function
getParentModule
()
{
return
$this
->
_parentModule
;
}
/**
* Checks whether the named module exists.
* @param string $id module ID
* @return boolean whether the named module exists. Both loaded and unloaded modules
...
...
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