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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
c210de9d
Commit
c210de9d
authored
Jun 19, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #556 from creocoder/php5.3-way-to-get-namespace
Model::formName() and ActiveRecord::getNamespacedClass() PHP 5.3 way
parents
729446ed
826c83c3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
Model.php
framework/yii/base/Model.php
+2
-3
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+4
-5
No files found.
framework/yii/base/Model.php
View file @
c210de9d
...
...
@@ -186,9 +186,8 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
*/
public
function
formName
()
{
$class
=
get_class
(
$this
);
$pos
=
strrpos
(
$class
,
'\\'
);
return
$pos
===
false
?
$class
:
substr
(
$class
,
$pos
+
1
);
$reflector
=
new
\ReflectionClass
(
$this
);
return
$reflector
->
getShortName
();
}
/**
...
...
framework/yii/db/ActiveRecord.php
View file @
c210de9d
...
...
@@ -1390,13 +1390,12 @@ class ActiveRecord extends Model
protected
function
getNamespacedClass
(
$class
)
{
if
(
strpos
(
$class
,
'\\'
)
===
false
)
{
$primaryClass
=
get_class
(
$this
);
if
((
$pos
=
strrpos
(
$primaryClass
,
'\\'
))
!==
false
)
{
return
substr
(
$primaryClass
,
0
,
$pos
+
1
)
.
$class
;
}
}
$reflector
=
new
\ReflectionClass
(
$this
);
return
$reflector
->
getNamespaceName
()
.
'\\'
.
$class
;
}
else
{
return
$class
;
}
}
/**
* @param array $link
...
...
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