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
e26188b3
Commit
e26188b3
authored
Feb 19, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
URL wip
parent
e5be6868
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
UrlManager.php
framework/web/UrlManager.php
+16
-7
No files found.
framework/web/UrlManager.php
View file @
e26188b3
...
@@ -58,6 +58,14 @@ class UrlManager extends Component
...
@@ -58,6 +58,14 @@ class UrlManager extends Component
* This will be passed to [[\Yii::createObject()]] to create the URL rule instances.
* This will be passed to [[\Yii::createObject()]] to create the URL rule instances.
*/
*/
public
$defaultRuleClass
=
'yii\web\UrlRule'
;
public
$defaultRuleClass
=
'yii\web\UrlRule'
;
/**
* @var string the base URL of the application (the part after host name and before query string).
* Make sure any ending slashes be removed. If this property is not set, it will be determined
* according to the current request. should be removed. The URLs created via [[createUrl()]] will
* be prefixed with the value of this property.
*/
public
$baseUrl
;
public
$hostInfo
;
/**
/**
* Initializes the application component.
* Initializes the application component.
...
@@ -140,13 +148,17 @@ class UrlManager extends Component
...
@@ -140,13 +148,17 @@ class UrlManager extends Component
$route
=
trim
(
$route
,
'/'
);
$route
=
trim
(
$route
,
'/'
);
$baseUrl
=
$this
->
getBaseUrl
();
if
(
$this
->
baseUrl
===
null
)
{
/** @var $request \yii\web\Request */
$request
=
Yii
::
$app
->
getRequest
();
$this
->
baseUrl
=
$this
->
showScriptName
||
!
$this
->
enablePrettyUrl
?
$request
->
getScriptUrl
()
:
$request
->
getBaseUrl
();
}
if
(
$this
->
enablePrettyUrl
)
{
if
(
$this
->
enablePrettyUrl
)
{
/** @var $rule UrlRule */
/** @var $rule UrlRule */
foreach
(
$this
->
rules
as
$rule
)
{
foreach
(
$this
->
rules
as
$rule
)
{
if
((
$url
=
$rule
->
createUrl
(
$this
,
$route
,
$params
))
!==
false
)
{
if
((
$url
=
$rule
->
createUrl
(
$this
,
$route
,
$params
))
!==
false
)
{
return
$baseUrl
.
$url
.
$anchor
;
return
$
this
->
baseUrl
.
$url
.
$anchor
;
}
}
}
}
...
@@ -156,13 +168,10 @@ class UrlManager extends Component
...
@@ -156,13 +168,10 @@ class UrlManager extends Component
if
(
$params
!==
array
())
{
if
(
$params
!==
array
())
{
$route
.=
'?'
.
http_build_query
(
$params
);
$route
.=
'?'
.
http_build_query
(
$params
);
}
}
return
$baseUrl
.
'/'
.
$route
.
$anchor
;
return
$
this
->
baseUrl
.
'/'
.
$route
.
$anchor
;
}
else
{
}
else
{
$params
[
$this
->
routeVar
]
=
$route
;
$params
[
$this
->
routeVar
]
=
$route
;
if
(
!
$this
->
showScriptName
)
{
return
$this
->
baseUrl
.
'?'
.
http_build_query
(
$params
)
.
$anchor
;
$baseUrl
.=
'/'
;
}
return
$baseUrl
.
'?'
.
http_build_query
(
$params
)
.
$anchor
;
}
}
}
}
...
...
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