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
210e7b69
Commit
210e7b69
authored
Mar 04, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
60583b87
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
7 deletions
+53
-7
YiiBase.php
framework/YiiBase.php
+1
-1
Application.php
framework/base/Application.php
+0
-2
Request.php
framework/base/Request.php
+7
-1
Request.php
framework/console/Request.php
+4
-0
Application.php
framework/web/Application.php
+21
-3
Request.php
framework/web/Request.php
+20
-0
No files found.
framework/YiiBase.php
View file @
210e7b69
...
@@ -63,7 +63,7 @@ class YiiBase
...
@@ -63,7 +63,7 @@ class YiiBase
*/
*/
public
static
$classPath
=
array
();
public
static
$classPath
=
array
();
/**
/**
* @var yii\
base
\Application the application instance
* @var yii\
console\Application|yii\web
\Application the application instance
*/
*/
public
static
$app
;
public
static
$app
;
/**
/**
...
...
framework/base/Application.php
View file @
210e7b69
...
@@ -398,8 +398,6 @@ class Application extends Module
...
@@ -398,8 +398,6 @@ class Application extends Module
public
function
registerDefaultAliases
()
public
function
registerDefaultAliases
()
{
{
Yii
::
$aliases
[
'@app'
]
=
$this
->
getBasePath
();
Yii
::
$aliases
[
'@app'
]
=
$this
->
getBasePath
();
Yii
::
$aliases
[
'@entry'
]
=
dirname
(
$_SERVER
[
'SCRIPT_FILENAME'
]);
Yii
::
$aliases
[
'@www'
]
=
''
;
}
}
/**
/**
...
...
framework/base/Request.php
View file @
210e7b69
...
@@ -13,12 +13,18 @@ namespace yii\base;
...
@@ -13,12 +13,18 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Request
extends
Component
abstract
class
Request
extends
Component
{
{
private
$_scriptFile
;
private
$_scriptFile
;
private
$_isConsoleRequest
;
private
$_isConsoleRequest
;
/**
/**
* Resolves the current request into a route and the associated parameters.
* @return array the first element is the route, and the second is the associated parameters.
*/
abstract
public
function
resolve
();
/**
* Returns a value indicating whether the current request is made via command line
* Returns a value indicating whether the current request is made via command line
* @return boolean the value indicating whether the current request is made via console
* @return boolean the value indicating whether the current request is made via console
*/
*/
...
...
framework/console/Request.php
View file @
210e7b69
...
@@ -22,6 +22,10 @@ class Request extends \yii\base\Request
...
@@ -22,6 +22,10 @@ class Request extends \yii\base\Request
return
isset
(
$_SERVER
[
'argv'
])
?
$_SERVER
[
'argv'
]
:
array
();
return
isset
(
$_SERVER
[
'argv'
])
?
$_SERVER
[
'argv'
]
:
array
();
}
}
/**
* Resolves the current request into a route and the associated parameters.
* @return array the first element is the route, and the second is the associated parameters.
*/
public
function
resolve
()
public
function
resolve
()
{
{
$rawParams
=
$this
->
getRawParams
();
$rawParams
=
$this
->
getRawParams
();
...
...
framework/web/Application.php
View file @
210e7b69
...
@@ -23,7 +23,7 @@ class Application extends \yii\base\Application
...
@@ -23,7 +23,7 @@ class Application extends \yii\base\Application
public
function
registerDefaultAliases
()
public
function
registerDefaultAliases
()
{
{
parent
::
registerDefaultAliases
();
parent
::
registerDefaultAliases
();
\Yii
::
$aliases
[
'@w
ww
'
]
=
dirname
(
$_SERVER
[
'SCRIPT_FILENAME'
]);
\Yii
::
$aliases
[
'@w
ebroot
'
]
=
dirname
(
$_SERVER
[
'SCRIPT_FILENAME'
]);
}
}
/**
/**
...
@@ -32,8 +32,8 @@ class Application extends \yii\base\Application
...
@@ -32,8 +32,8 @@ class Application extends \yii\base\Application
*/
*/
public
function
processRequest
()
public
function
processRequest
()
{
{
$route
=
$this
->
getUrlManager
()
->
parseRequest
(
$this
->
getRequest
()
);
list
(
$route
,
$params
)
=
$this
->
getRequest
()
->
resolve
(
);
return
$this
->
runAction
(
$route
,
$
_GET
);
return
$this
->
runAction
(
$route
,
$
params
);
}
}
/**
/**
...
@@ -46,6 +46,24 @@ class Application extends \yii\base\Application
...
@@ -46,6 +46,24 @@ class Application extends \yii\base\Application
}
}
/**
/**
* Returns the response component.
* @return Response the response component
*/
public
function
getResponse
()
{
return
$this
->
getComponent
(
'response'
);
}
/**
* Returns the session component.
* @return Session the session component
*/
public
function
getSession
()
{
return
$this
->
getComponent
(
'session'
);
}
/**
* @return UrlManager
* @return UrlManager
*/
*/
public
function
getUrlManager
()
public
function
getUrlManager
()
...
...
framework/web/Request.php
View file @
210e7b69
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
namespace
yii\web
;
namespace
yii\web
;
use
Yii
;
use
Yii
;
use
yii\base\HttpException
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
/**
/**
...
@@ -38,6 +39,25 @@ class Request extends \yii\base\Request
...
@@ -38,6 +39,25 @@ class Request extends \yii\base\Request
private
$_cookies
;
private
$_cookies
;
/**
/**
* Resolves the current request into a route and the associated parameters.
* @return array the first element is the route, and the second is the associated parameters.
* @throws HttpException if the request cannot be resolved.
*/
public
function
resolve
()
{
Yii
::
setAlias
(
'@www'
,
$this
->
getBaseUrl
());
$result
=
Yii
::
$app
->
getUrlManager
()
->
parseRequest
(
$this
);
if
(
$result
!==
false
)
{
list
(
$route
,
$params
)
=
$result
;
$params
=
array_merge
(
$_GET
,
$params
);
return
array
(
$route
,
$params
);
}
else
{
throw
new
HttpException
(
404
,
Yii
::
t
(
'yii|Page not found.'
));
}
}
/**
* Returns the method of the current request (e.g. GET, POST, HEAD, PUT, DELETE).
* Returns the method of the current request (e.g. GET, POST, HEAD, PUT, DELETE).
* @return string request method, such as GET, POST, HEAD, PUT, DELETE.
* @return string request method, such as GET, POST, HEAD, PUT, DELETE.
* The value returned is turned into upper case.
* The value returned is turned into upper case.
...
...
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