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
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
Hide 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,12 +1390,11 @@ class ActiveRecord extends Model
protected
function
getNamespacedClass
(
$class
)
{
if
(
strpos
(
$class
,
'\\'
)
===
false
)
{
$
primaryClass
=
get_c
lass
(
$this
);
if
((
$pos
=
strrpos
(
$primaryClass
,
'\\'
))
!==
false
)
{
return
substr
(
$primaryClass
,
0
,
$pos
+
1
)
.
$class
;
}
$
reflector
=
new
\ReflectionC
lass
(
$this
);
return
$reflector
->
getNamespaceName
()
.
'\\'
.
$class
;
}
else
{
return
$class
;
}
return
$class
;
}
/**
...
...
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