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
cceb5b11
Commit
cceb5b11
authored
Jun 06, 2013
by
Gevik Babakhani
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master' into pgsql-driver
parents
70e97312
3aa640e7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
47 deletions
+42
-47
Application.php
framework/yii/base/Application.php
+28
-34
Module.php
framework/yii/base/Module.php
+3
-0
Target.php
framework/yii/logging/Target.php
+0
-2
AccessRule.php
framework/yii/web/AccessRule.php
+1
-1
HttpCache.php
framework/yii/web/HttpCache.php
+1
-1
Request.php
framework/yii/web/Request.php
+7
-7
UrlRule.php
framework/yii/web/UrlRule.php
+1
-1
VerbFilter.php
framework/yii/web/VerbFilter.php
+1
-1
No files found.
framework/yii/base/Application.php
View file @
cceb5b11
...
@@ -67,10 +67,20 @@ class Application extends Module
...
@@ -67,10 +67,20 @@ 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
;
if
(
!
isset
(
$config
[
'id'
]))
{
throw
new
InvalidConfigException
(
'The "id" configuration is required.'
);
}
if
(
isset
(
$config
[
'basePath'
]))
{
$this
->
setBasePath
(
$config
[
'basePath'
]);
unset
(
$config
[
'basePath'
]);
}
else
{
throw
new
InvalidConfigException
(
'The "basePath" configuration is required.'
);
}
$this
->
preInit
(
$config
);
$this
->
preInit
(
$config
);
...
@@ -83,37 +93,24 @@ class Application extends Module
...
@@ -83,37 +93,24 @@ class Application extends Module
/**
/**
* Pre-initializes the application.
* Pre-initializes the application.
* This method is called at the beginning of the application constructor.
* 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
* @param array $config the application configuration
* @throws InvalidConfigException if either [[id]] or [[basePath]] configuration is missing.
*/
*/
public
function
preInit
(
$config
)
public
function
preInit
(
&
$config
)
{
{
if
(
!
isset
(
$config
[
'id'
]))
{
if
(
isset
(
$config
[
'vendorPath'
]))
{
throw
new
InvalidConfigException
(
'The "id" configuration is required.'
);
$this
->
setVendorPath
(
$config
[
'vendorPath'
]);
}
if
(
!
isset
(
$config
[
'basePath'
]))
{
throw
new
InvalidConfigException
(
'The "basePath" configuration is required.'
);
}
$this
->
setBasePath
(
$config
[
'basePath'
]);
Yii
::
setAlias
(
'@app'
,
$this
->
getBasePath
());
unset
(
$config
[
'basePath'
]);
if
(
isset
(
$config
[
'vendor'
]))
{
$this
->
setVendorPath
(
$config
[
'vendor'
]);
unset
(
$config
[
'vendorPath'
]);
unset
(
$config
[
'vendorPath'
]);
}
else
{
// set "@vendor"
$this
->
getVendorPath
();
}
}
Yii
::
setAlias
(
'@vendor'
,
$this
->
getVendorPath
());
if
(
isset
(
$config
[
'runtimePath'
]))
{
$this
->
setRuntimePath
(
$config
[
'runtimePath'
]);
if
(
isset
(
$config
[
'runtime'
]))
{
unset
(
$config
[
'runtimePath'
]);
$this
->
setRuntimePath
(
$config
[
'runtime'
]);
}
else
{
unset
(
$config
[
'runtime'
]);
// set "@runtime"
$this
->
getRuntimePath
();
}
}
Yii
::
setAlias
(
'@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'
]);
...
@@ -202,7 +199,8 @@ class Application extends Module
...
@@ -202,7 +199,8 @@ class Application extends Module
/**
/**
* Returns the directory that stores runtime files.
* Returns the directory that stores runtime files.
* @return string the directory that stores runtime files. Defaults to 'protected/runtime'.
* @return string the directory that stores runtime files.
* Defaults to the "runtime" subdirectory under [[basePath]].
*/
*/
public
function
getRuntimePath
()
public
function
getRuntimePath
()
{
{
...
@@ -215,16 +213,11 @@ class Application extends Module
...
@@ -215,16 +213,11 @@ class Application extends Module
/**
/**
* Sets the directory that stores runtime files.
* Sets the directory that stores runtime files.
* @param string $path the directory that stores runtime files.
* @param string $path the directory that stores runtime files.
* @throws InvalidConfigException if the directory does not exist or is not writable
*/
*/
public
function
setRuntimePath
(
$path
)
public
function
setRuntimePath
(
$path
)
{
{
$path
=
Yii
::
getAlias
(
$path
);
$this
->
_runtimePath
=
Yii
::
getAlias
(
$path
);
if
(
is_dir
(
$path
)
&&
is_writable
(
$path
))
{
Yii
::
setAlias
(
'@runtime'
,
$this
->
_runtimePath
);
$this
->
_runtimePath
=
$path
;
}
else
{
throw
new
InvalidConfigException
(
"Runtime path must be a directory writable by the Web server process:
$path
"
);
}
}
}
private
$_vendorPath
;
private
$_vendorPath
;
...
@@ -232,7 +225,7 @@ class Application extends Module
...
@@ -232,7 +225,7 @@ class Application extends Module
/**
/**
* Returns the directory that stores vendor files.
* Returns the directory that stores vendor files.
* @return string the directory that stores vendor files.
* @return string the directory that stores vendor files.
* Defaults to
'vendor' directory under applications
[[basePath]].
* Defaults to
"vendor" directory under
[[basePath]].
*/
*/
public
function
getVendorPath
()
public
function
getVendorPath
()
{
{
...
@@ -249,6 +242,7 @@ class Application extends Module
...
@@ -249,6 +242,7 @@ class Application extends Module
public
function
setVendorPath
(
$path
)
public
function
setVendorPath
(
$path
)
{
{
$this
->
_vendorPath
=
Yii
::
getAlias
(
$path
);
$this
->
_vendorPath
=
Yii
::
getAlias
(
$path
);
Yii
::
setAlias
(
'@vendor'
,
$this
->
_vendorPath
);
}
}
/**
/**
...
...
framework/yii/base/Module.php
View file @
cceb5b11
...
@@ -236,6 +236,9 @@ abstract class Module extends Component
...
@@ -236,6 +236,9 @@ abstract class Module extends Component
$p
=
realpath
(
$path
);
$p
=
realpath
(
$path
);
if
(
$p
!==
false
&&
is_dir
(
$p
))
{
if
(
$p
!==
false
&&
is_dir
(
$p
))
{
$this
->
_basePath
=
$p
;
$this
->
_basePath
=
$p
;
if
(
$this
instanceof
Application
)
{
Yii
::
setAlias
(
'@app'
,
$p
);
}
}
else
{
}
else
{
throw
new
InvalidParamException
(
"The directory does not exist:
$path
"
);
throw
new
InvalidParamException
(
"The directory does not exist:
$path
"
);
}
}
...
...
framework/yii/logging/Target.php
View file @
cceb5b11
...
@@ -204,14 +204,12 @@ abstract class Target extends Component
...
@@ -204,14 +204,12 @@ abstract class Target extends Component
if
(
$matched
)
{
if
(
$matched
)
{
foreach
(
$this
->
except
as
$category
)
{
foreach
(
$this
->
except
as
$category
)
{
$prefix
=
rtrim
(
$category
,
'*'
);
$prefix
=
rtrim
(
$category
,
'*'
);
foreach
(
$messages
as
$i
=>
$message
)
{
if
(
strpos
(
$message
[
2
],
$prefix
)
===
0
&&
(
$message
[
2
]
===
$category
||
$prefix
!==
$category
))
{
if
(
strpos
(
$message
[
2
],
$prefix
)
===
0
&&
(
$message
[
2
]
===
$category
||
$prefix
!==
$category
))
{
$matched
=
false
;
$matched
=
false
;
break
;
break
;
}
}
}
}
}
}
}
if
(
!
$matched
)
{
if
(
!
$matched
)
{
unset
(
$messages
[
$i
]);
unset
(
$messages
[
$i
]);
...
...
framework/yii/web/AccessRule.php
View file @
cceb5b11
...
@@ -99,7 +99,7 @@ class AccessRule extends Component
...
@@ -99,7 +99,7 @@ class AccessRule extends Component
if
(
$this
->
matchAction
(
$action
)
if
(
$this
->
matchAction
(
$action
)
&&
$this
->
matchRole
(
$user
)
&&
$this
->
matchRole
(
$user
)
&&
$this
->
matchIP
(
$request
->
getUserIP
())
&&
$this
->
matchIP
(
$request
->
getUserIP
())
&&
$this
->
matchVerb
(
$request
->
get
Request
Method
())
&&
$this
->
matchVerb
(
$request
->
getMethod
())
&&
$this
->
matchController
(
$action
->
controller
)
&&
$this
->
matchController
(
$action
->
controller
)
&&
$this
->
matchCustom
(
$action
)
&&
$this
->
matchCustom
(
$action
)
)
{
)
{
...
...
framework/yii/web/HttpCache.php
View file @
cceb5b11
...
@@ -60,7 +60,7 @@ class HttpCache extends ActionFilter
...
@@ -60,7 +60,7 @@ class HttpCache extends ActionFilter
*/
*/
public
function
beforeAction
(
$action
)
public
function
beforeAction
(
$action
)
{
{
$verb
=
Yii
::
$app
->
request
->
get
Request
Method
();
$verb
=
Yii
::
$app
->
request
->
getMethod
();
if
(
$verb
!==
'GET'
&&
$verb
!==
'HEAD'
||
$this
->
lastModified
===
null
&&
$this
->
etagSeed
===
null
)
{
if
(
$verb
!==
'GET'
&&
$verb
!==
'HEAD'
||
$this
->
lastModified
===
null
&&
$this
->
etagSeed
===
null
)
{
return
true
;
return
true
;
}
}
...
...
framework/yii/web/Request.php
View file @
cceb5b11
...
@@ -49,7 +49,7 @@ class Request extends \yii\base\Request
...
@@ -49,7 +49,7 @@ class Request extends \yii\base\Request
/**
/**
* @var string|boolean the name of the POST parameter that is used to indicate if a request is a PUT or DELETE
* @var string|boolean the name of the POST parameter that is used to indicate if a request is a PUT or DELETE
* request tunneled through POST. Default to '_method'.
* request tunneled through POST. Default to '_method'.
* @see get
Request
Method
* @see getMethod
* @see getRestParams
* @see getRestParams
*/
*/
public
$restVar
=
'_method'
;
public
$restVar
=
'_method'
;
...
@@ -81,7 +81,7 @@ class Request extends \yii\base\Request
...
@@ -81,7 +81,7 @@ class Request extends \yii\base\Request
* @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.
*/
*/
public
function
get
Request
Method
()
public
function
getMethod
()
{
{
if
(
isset
(
$_POST
[
$this
->
restVar
]))
{
if
(
isset
(
$_POST
[
$this
->
restVar
]))
{
return
strtoupper
(
$_POST
[
$this
->
restVar
]);
return
strtoupper
(
$_POST
[
$this
->
restVar
]);
...
@@ -96,7 +96,7 @@ class Request extends \yii\base\Request
...
@@ -96,7 +96,7 @@ class Request extends \yii\base\Request
*/
*/
public
function
getIsPostRequest
()
public
function
getIsPostRequest
()
{
{
return
$this
->
get
Request
Method
()
===
'POST'
;
return
$this
->
getMethod
()
===
'POST'
;
}
}
/**
/**
...
@@ -105,7 +105,7 @@ class Request extends \yii\base\Request
...
@@ -105,7 +105,7 @@ class Request extends \yii\base\Request
*/
*/
public
function
getIsDeleteRequest
()
public
function
getIsDeleteRequest
()
{
{
return
$this
->
get
Request
Method
()
===
'DELETE'
;
return
$this
->
getMethod
()
===
'DELETE'
;
}
}
/**
/**
...
@@ -114,7 +114,7 @@ class Request extends \yii\base\Request
...
@@ -114,7 +114,7 @@ class Request extends \yii\base\Request
*/
*/
public
function
getIsPutRequest
()
public
function
getIsPutRequest
()
{
{
return
$this
->
get
Request
Method
()
===
'PUT'
;
return
$this
->
getMethod
()
===
'PUT'
;
}
}
/**
/**
...
@@ -141,7 +141,7 @@ class Request extends \yii\base\Request
...
@@ -141,7 +141,7 @@ class Request extends \yii\base\Request
/**
/**
* Returns the request parameters for the RESTful request.
* Returns the request parameters for the RESTful request.
* @return array the RESTful request parameters
* @return array the RESTful request parameters
* @see get
Request
Method
* @see getMethod
*/
*/
public
function
getRestParams
()
public
function
getRestParams
()
{
{
...
@@ -772,7 +772,7 @@ class Request extends \yii\base\Request
...
@@ -772,7 +772,7 @@ class Request extends \yii\base\Request
if
(
!
$this
->
enableCsrfValidation
)
{
if
(
!
$this
->
enableCsrfValidation
)
{
return
;
return
;
}
}
$method
=
$this
->
get
Request
Method
();
$method
=
$this
->
getMethod
();
if
(
$method
===
'POST'
||
$method
===
'PUT'
||
$method
===
'DELETE'
)
{
if
(
$method
===
'POST'
||
$method
===
'PUT'
||
$method
===
'DELETE'
)
{
$cookies
=
$this
->
getCookies
();
$cookies
=
$this
->
getCookies
();
switch
(
$method
)
{
switch
(
$method
)
{
...
...
framework/yii/web/UrlRule.php
View file @
cceb5b11
...
@@ -171,7 +171,7 @@ class UrlRule extends Object
...
@@ -171,7 +171,7 @@ class UrlRule extends Object
return
false
;
return
false
;
}
}
if
(
$this
->
verb
!==
null
&&
!
in_array
(
$request
->
get
Request
Method
(),
$this
->
verb
,
true
))
{
if
(
$this
->
verb
!==
null
&&
!
in_array
(
$request
->
getMethod
(),
$this
->
verb
,
true
))
{
return
false
;
return
false
;
}
}
...
...
framework/yii/web/VerbFilter.php
View file @
cceb5b11
...
@@ -76,7 +76,7 @@ class VerbFilter extends Behavior
...
@@ -76,7 +76,7 @@ class VerbFilter extends Behavior
{
{
$action
=
$event
->
action
->
id
;
$action
=
$event
->
action
->
id
;
if
(
isset
(
$this
->
actions
[
$action
]))
{
if
(
isset
(
$this
->
actions
[
$action
]))
{
$verb
=
Yii
::
$app
->
getRequest
()
->
get
Request
Method
();
$verb
=
Yii
::
$app
->
getRequest
()
->
getMethod
();
$allowed
=
array_map
(
'strtoupper'
,
$this
->
actions
[
$action
]);
$allowed
=
array_map
(
'strtoupper'
,
$this
->
actions
[
$action
]);
if
(
!
in_array
(
$verb
,
$allowed
))
{
if
(
!
in_array
(
$verb
,
$allowed
))
{
$event
->
isValid
=
false
;
$event
->
isValid
=
false
;
...
...
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