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
43746163
Commit
43746163
authored
Mar 19, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
throw exception when UrlManager is not properly configured in console mode.
parent
62fae9c1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
UrlManager.php
framework/web/UrlManager.php
+12
-2
No files found.
framework/web/UrlManager.php
View file @
43746163
...
@@ -310,13 +310,17 @@ class UrlManager extends Component
...
@@ -310,13 +310,17 @@ class UrlManager extends Component
* It defaults to [[Request::scriptUrl]] if [[showScriptName]] is true or [[enablePrettyUrl]] is false;
* It defaults to [[Request::scriptUrl]] if [[showScriptName]] is true or [[enablePrettyUrl]] is false;
* otherwise, it defaults to [[Request::baseUrl]].
* otherwise, it defaults to [[Request::baseUrl]].
* @return string the base URL that is used by [[createUrl()]] to prepend URLs it creates.
* @return string the base URL that is used by [[createUrl()]] to prepend URLs it creates.
* @throws InvalidConfigException if running in console application and [[baseUrl]] is not configured.
*/
*/
public
function
getBaseUrl
()
public
function
getBaseUrl
()
{
{
if
(
$this
->
_baseUrl
===
null
)
{
if
(
$this
->
_baseUrl
===
null
)
{
/** @var \yii\web\Request $request */
$request
=
Yii
::
$app
->
getRequest
();
$request
=
Yii
::
$app
->
getRequest
();
if
(
$request
instanceof
\yii\web\Request
)
{
$this
->
_baseUrl
=
$this
->
showScriptName
||
!
$this
->
enablePrettyUrl
?
$request
->
getScriptUrl
()
:
$request
->
getBaseUrl
();
$this
->
_baseUrl
=
$this
->
showScriptName
||
!
$this
->
enablePrettyUrl
?
$request
->
getScriptUrl
()
:
$request
->
getBaseUrl
();
}
else
{
throw
new
InvalidConfigException
(
'Please configure UrlManager::baseUrl correctly as you are running a console application.'
);
}
}
}
return
$this
->
_baseUrl
;
return
$this
->
_baseUrl
;
...
@@ -334,11 +338,17 @@ class UrlManager extends Component
...
@@ -334,11 +338,17 @@ class UrlManager extends Component
/**
/**
* Returns the host info that is used by [[createAbsoluteUrl()]] to prepend URLs it creates.
* Returns the host info that is used by [[createAbsoluteUrl()]] to prepend URLs it creates.
* @return string the host info (e.g. "http://www.example.com") that is used by [[createAbsoluteUrl()]] to prepend URLs it creates.
* @return string the host info (e.g. "http://www.example.com") that is used by [[createAbsoluteUrl()]] to prepend URLs it creates.
* @throws InvalidConfigException if running in console application and [[hostInfo]] is not configured.
*/
*/
public
function
getHostInfo
()
public
function
getHostInfo
()
{
{
if
(
$this
->
_hostInfo
===
null
)
{
if
(
$this
->
_hostInfo
===
null
)
{
$this
->
_hostInfo
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
();
$request
=
Yii
::
$app
->
getRequest
();
if
(
$request
instanceof
\yii\web\Request
)
{
$this
->
_hostInfo
=
$request
->
getHostInfo
();
}
else
{
throw
new
InvalidConfigException
(
'Please configure UrlManager::hostInfo correctly as you are running a console application.'
);
}
}
}
return
$this
->
_hostInfo
;
return
$this
->
_hostInfo
;
...
...
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