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
33d6acba
Commit
33d6acba
authored
Feb 26, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved behavior support, fixes #2550
call hasMethod() instead of using method_exists
parent
6f9e9cd5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
Formatter.php
framework/base/Formatter.php
+1
-1
ActiveRelationTrait.php
framework/db/ActiveRelationTrait.php
+2
-2
Validator.php
framework/validators/Validator.php
+1
-1
No files found.
framework/base/Formatter.php
View file @
33d6acba
...
...
@@ -121,7 +121,7 @@ class Formatter extends Component
$params
=
[
$value
];
}
$method
=
'as'
.
$format
;
if
(
method_exists
(
$this
,
$method
))
{
if
(
$this
->
hasMethod
(
$method
))
{
return
call_user_func_array
([
$this
,
$method
],
$params
);
}
else
{
throw
new
InvalidParamException
(
"Unknown type:
$format
"
);
...
...
framework/db/ActiveRelationTrait.php
View file @
33d6acba
...
...
@@ -136,13 +136,13 @@ trait ActiveRelationTrait
* Finds the related records for the specified primary record.
* This method is invoked when a relation of an ActiveRecord is being accessed in a lazy fashion.
* @param string $name the relation name
* @param ActiveRecordInterface $model the primary model
* @param ActiveRecordInterface
|BaseActiveRecord
$model the primary model
* @return mixed the related record(s)
* @throws InvalidParamException if the relation is invalid
*/
public
function
findFor
(
$name
,
$model
)
{
if
(
method_exists
(
$model
,
'get'
.
$name
))
{
if
(
$model
->
hasMethod
(
'get'
.
$name
))
{
$method
=
new
\ReflectionMethod
(
$model
,
'get'
.
$name
);
$realName
=
lcfirst
(
substr
(
$method
->
getName
(),
3
));
if
(
$realName
!==
$name
)
{
...
...
framework/validators/Validator.php
View file @
33d6acba
...
...
@@ -136,7 +136,7 @@ class Validator extends Component
{
$params
[
'attributes'
]
=
$attributes
;
if
(
$type
instanceof
\Closure
||
method_exists
(
$object
,
$type
))
{
if
(
$type
instanceof
\Closure
||
$object
->
hasMethod
(
$type
))
{
// method-based validator
$params
[
'class'
]
=
__NAMESPACE__
.
'\InlineValidator'
;
$params
[
'method'
]
=
$type
;
...
...
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