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
36bbfd54
Commit
36bbfd54
authored
Jun 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented "@app/runtime" alias.
parent
607f3a59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
20 deletions
+34
-20
Application.php
framework/yii/base/Application.php
+32
-14
FileCache.php
framework/yii/caching/FileCache.php
+2
-6
No files found.
framework/yii/base/Application.php
View file @
36bbfd54
...
@@ -67,35 +67,53 @@ class Application extends Module
...
@@ -67,35 +67,53 @@ class Application extends Module
* Constructor.
* Constructor.
* @param array $config name-value pairs that will be used to initialize the object properties.
* @param array $config name-value pairs that will be used to initialize the object properties.
* Note that the configuration must contain both [[id]] and [[basePath]].
* Note that the configuration must contain both [[id]] and [[basePath]].
* @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
*/
*/
public
function
__construct
(
$config
=
array
())
public
function
__construct
(
$config
=
array
())
{
{
Yii
::
$app
=
$this
;
Yii
::
$app
=
$this
;
$this
->
preInit
(
$config
);
$this
->
registerErrorHandlers
();
$this
->
registerCoreComponents
();
Component
::
__construct
(
$config
);
}
/**
* Pre-initializes the application.
* This method is called at the beginning of the application constructor.
* When this method is called, none of the application properties are initialized yet.
* The default implementation will initialize a few important properties
* that may be referenced during the initialization of the rest of the properties.
* @param array $config the application configuration
* @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
*/
public
function
preInit
(
$config
)
{
if
(
!
isset
(
$config
[
'id'
]))
{
if
(
!
isset
(
$config
[
'id'
]))
{
throw
new
InvalidConfigException
(
'The "id" configuration is required.'
);
throw
new
InvalidConfigException
(
'The "id" configuration is required.'
);
}
}
if
(
!
isset
(
$config
[
'basePath'
]))
{
if
(
isset
(
$config
[
'basePath'
]))
{
$this
->
setBasePath
(
$config
[
'basePath'
]);
Yii
::
setAlias
(
'@app'
,
$this
->
getBasePath
());
unset
(
$config
[
'basePath'
]);
}
else
{
throw
new
InvalidConfigException
(
'The "basePath" configuration is required.'
);
throw
new
InvalidConfigException
(
'The "basePath" configuration is required.'
);
}
}
$this
->
setBasePath
(
$config
[
'basePath'
]);
Yii
::
setAlias
(
'@app'
,
$this
->
getBasePath
());
unset
(
$config
[
'basePath'
]);
if
(
isset
(
$config
[
'runtime'
]))
{
$this
->
setRuntimePath
(
$config
[
'runtime'
]);
unset
(
$config
[
'runtime'
]);
}
Yii
::
setAlias
(
'@app/runtime'
,
$this
->
getRuntimePath
());
if
(
isset
(
$config
[
'timeZone'
]))
{
if
(
isset
(
$config
[
'timeZone'
]))
{
$this
->
setTimeZone
(
$config
[
'timeZone'
]);
$this
->
setTimeZone
(
$config
[
'timeZone'
]);
unset
(
$config
[
'timeZone'
]);
unset
(
$config
[
'timeZone'
]);
}
elseif
(
!
ini_get
(
'date.timezone'
))
{
}
elseif
(
!
ini_get
(
'date.timezone'
))
{
$this
->
setTimeZone
(
'UTC'
);
$this
->
setTimeZone
(
'UTC'
);
}
}
$this
->
registerErrorHandlers
();
$this
->
registerCoreComponents
();
Component
::
__construct
(
$config
);
}
}
/**
/**
...
...
framework/yii/caching/FileCache.php
View file @
36bbfd54
...
@@ -27,7 +27,7 @@ class FileCache extends Cache
...
@@ -27,7 +27,7 @@ class FileCache extends Cache
* @var string the directory to store cache files. You may use path alias here.
* @var string the directory to store cache files. You may use path alias here.
* If not set, it will use the "cache" subdirectory under the application runtime path.
* If not set, it will use the "cache" subdirectory under the application runtime path.
*/
*/
public
$cachePath
;
public
$cachePath
=
'@app/runtime/cache'
;
/**
/**
* @var string cache file suffix. Defaults to '.bin'.
* @var string cache file suffix. Defaults to '.bin'.
*/
*/
...
@@ -52,11 +52,7 @@ class FileCache extends Cache
...
@@ -52,11 +52,7 @@ class FileCache extends Cache
public
function
init
()
public
function
init
()
{
{
parent
::
init
();
parent
::
init
();
if
(
$this
->
cachePath
===
null
)
{
$this
->
cachePath
=
Yii
::
getAlias
(
$this
->
cachePath
);
$this
->
cachePath
=
Yii
::
$app
->
getRuntimePath
()
.
DIRECTORY_SEPARATOR
.
'cache'
;
}
else
{
$this
->
cachePath
=
Yii
::
getAlias
(
$this
->
cachePath
);
}
if
(
!
is_dir
(
$this
->
cachePath
))
{
if
(
!
is_dir
(
$this
->
cachePath
))
{
mkdir
(
$this
->
cachePath
,
0777
,
true
);
mkdir
(
$this
->
cachePath
,
0777
,
true
);
}
}
...
...
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