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
b6be7111
Commit
b6be7111
authored
Dec 16, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #6488: Support changing `yii\base\Theme::basePath` during runtime
parent
2202ae6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
19 deletions
+13
-19
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Theme.php
framework/base/Theme.php
+12
-19
No files found.
framework/CHANGELOG.md
View file @
b6be7111
...
...
@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
-
Enh #6247: Logger and error handler are now using slightly less memory (stepanselyuk, samdark)
-
Enh #6434: Added
`yii\behaviors\SluggableBehavior::immutable`
to support keeping the generated slug unchanged (trntv)
-
Enh #6467:
`ActiveForm`
will scroll to the nearest visible element when the first error input is hidden (newartix)
-
Enh #6488: Support changing
`yii\base\Theme::basePath`
during runtime (qiangxue)
-
Chg #6427: In case of invalid route web application now throws exception with "Page not found" instead of "Invalid Route" (cebe, samdark)
2.
0.1 December 07, 2014
...
...
framework/base/Theme.php
View file @
b6be7111
...
...
@@ -73,29 +73,12 @@ class Theme extends Component
{
/**
* @var array the mapping between view directories and their corresponding themed versions.
* If not set, it will be initialized as a mapping from [[Application::basePath]] to [[basePath]].
* This property is used by [[applyTo()]] when a view is trying to apply the theme.
* Path aliases can be used when specifying directories.
* If this property is empty or not set, a mapping [[Application::basePath]] to [[basePath]] will be used.
*/
public
$pathMap
;
/**
* Initializes the theme.
* @throws InvalidConfigException if [[basePath]] is not set.
*/
public
function
init
()
{
parent
::
init
();
if
(
empty
(
$this
->
pathMap
))
{
if
((
$basePath
=
$this
->
getBasePath
())
===
null
)
{
throw
new
InvalidConfigException
(
'The "basePath" property must be set.'
);
}
$this
->
pathMap
=
[
Yii
::
$app
->
getBasePath
()
=>
[
$basePath
]];
}
}
private
$_baseUrl
;
/**
...
...
@@ -142,11 +125,21 @@ class Theme extends Component
* If there is no corresponding themed file, the original file will be returned.
* @param string $path the file to be themed
* @return string the themed file, or the original file if the themed version is not available.
* @throws InvalidConfigException if [[basePath]] is not set
*/
public
function
applyTo
(
$path
)
{
$pathMap
=
$this
->
pathMap
;
if
(
empty
(
$pathMap
))
{
if
((
$basePath
=
$this
->
getBasePath
())
===
null
)
{
throw
new
InvalidConfigException
(
'The "basePath" property must be set.'
);
}
$pathMap
=
[
Yii
::
$app
->
getBasePath
()
=>
[
$basePath
]];
}
$path
=
FileHelper
::
normalizePath
(
$path
);
foreach
(
$this
->
pathMap
as
$from
=>
$tos
)
{
foreach
(
$pathMap
as
$from
=>
$tos
)
{
$from
=
FileHelper
::
normalizePath
(
Yii
::
getAlias
(
$from
))
.
DIRECTORY_SEPARATOR
;
if
(
strpos
(
$path
,
$from
)
===
0
)
{
$n
=
strlen
(
$from
);
...
...
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