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
e123428c
Commit
e123428c
authored
Jan 08, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed Yii autoloader to support loading PSR-4 classes only (i.e. PEAR-styled…
Changed Yii autoloader to support loading PSR-4 classes only (i.e. PEAR-styled classes not supported anymore)
parent
3902cada
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
22 deletions
+8
-22
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
BaseYii.php
framework/yii/BaseYii.php
+7
-22
No files found.
framework/CHANGELOG.md
View file @
e123428c
...
...
@@ -71,6 +71,7 @@ Yii Framework 2 Change Log
-
Chg: Added
`yii\widgets\InputWidget::options`
(qiangxue)
-
Chg: Changed the signature of
`urlCreator`
and button creators for
`yii\gridview\ActionColumn`
(qiangxue)
-
Chg: Updated HTMLPurified dependency to
`4.6.*`
.
-
Chg: Changed Yii autoloader to support loading PSR-4 classes only (i.e. PEAR-styled classes not supported anymore) (qiangxue)
-
New #66:
[
Auth client library
](
https://github.com/yiisoft/yii2-authclient
)
OpenId, OAuth1, OAuth2 clients (klimov-paul)
-
New #1393:
[
Codeception testing framework integration
](
https://github.com/yiisoft/yii2-codeception
)
(
Ragazzo
)
-
New #1438:
[
MongoDB integration
](
https://github.com/yiisoft/yii2-mongodb
)
ActiveRecord and Query (klimov-paul)
...
...
framework/yii/BaseYii.php
View file @
e123428c
...
...
@@ -266,12 +266,9 @@ class BaseYii
* 2. If the class is namespaced (e.g. `yii\base\Component`), it will attempt
* to include the file associated with the corresponding path alias
* (e.g. `@yii/base/Component.php`);
* 3. If the class is named in PEAR style (e.g. `PHPUnit_Framework_TestCase`),
* it will attempt to include the file associated with the corresponding path alias
* (e.g. `@PHPUnit/Framework/TestCase.php`);
*
* This autoloader allows loading classes that follow the [PSR-
0 standard](http://www.php-fig.org/psr/0/).
*
Therefor a path alias has to be defined for each top-level namespace
.
* This autoloader allows loading classes that follow the [PSR-
4 standard](http://www.php-fig.org/psr/psr-4/)
*
and have its top-level namespace defined as path aliases
.
*
* @param string $className the fully qualified class name without a leading backslash "\"
* @throws UnknownClassException if the class does not exist in the class file
...
...
@@ -283,25 +280,13 @@ class BaseYii
if
(
$classFile
[
0
]
===
'@'
)
{
$classFile
=
static
::
getAlias
(
$classFile
);
}
}
else
{
// follow PSR-0 to determine the class file
if
((
$pos
=
strrpos
(
$className
,
'\\'
))
!==
false
)
{
// namespaced class, e.g. yii\base\Component
$path
=
str_replace
(
'\\'
,
'/'
,
substr
(
$className
,
0
,
$pos
+
1
))
.
str_replace
(
'_'
,
'/'
,
substr
(
$className
,
$pos
+
1
))
.
'.php'
;
}
else
{
$path
=
str_replace
(
'_'
,
'/'
,
$className
)
.
'.php'
;
}
// try loading via path alias
if
(
strpos
(
$path
,
'/'
)
===
false
)
{
}
elseif
(
strpos
(
$className
,
'\\'
)
!==
false
)
{
$classFile
=
static
::
getAlias
(
'@'
.
str_replace
(
'\\'
,
'/'
,
$className
)
.
'.php'
,
false
);
if
(
$classFile
===
false
||
!
is_file
(
$classFile
))
{
return
;
}
else
{
$classFile
=
static
::
getAlias
(
'@'
.
$path
,
false
);
if
(
$classFile
===
false
||
!
is_file
(
$classFile
))
{
return
;
}
}
}
else
{
return
;
}
include
(
$classFile
);
...
...
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