Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
c0c81083
Commit
c0c81083
authored
Nov 01, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring the autoloader.
parent
a0bbc9d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
autoloader.php
laravel/autoloader.php
+8
-10
core.php
laravel/bootstrap/core.php
+1
-1
No files found.
laravel/autoloader.php
View file @
c0c81083
...
@@ -7,14 +7,14 @@ class Autoloader {
...
@@ -7,14 +7,14 @@ class Autoloader {
*
*
* @var array
* @var array
*/
*/
protected
$libraries
=
array
();
protected
static
$libraries
=
array
();
/**
/**
* The paths to be searched by the auto-loader.
* The paths to be searched by the auto-loader.
*
*
* @var array
* @var array
*/
*/
protected
$paths
=
array
(
BASE_PATH
,
MODEL_PATH
,
LIBRARY_PATH
);
protected
static
$paths
=
array
(
BASE_PATH
,
MODEL_PATH
,
LIBRARY_PATH
);
/**
/**
* Load the file corresponding to a given class.
* Load the file corresponding to a given class.
...
@@ -22,7 +22,7 @@ class Autoloader {
...
@@ -22,7 +22,7 @@ class Autoloader {
* @param string $class
* @param string $class
* @return void
* @return void
*/
*/
public
function
load
(
$class
)
public
static
function
load
(
$class
)
{
{
// Most of the core classes are aliases for convenient access in spite of
// Most of the core classes are aliases for convenient access in spite of
// the namespace. If an alias is defined for the class, we will load the
// the namespace. If an alias is defined for the class, we will load the
...
@@ -32,11 +32,9 @@ class Autoloader {
...
@@ -32,11 +32,9 @@ class Autoloader {
return
class_alias
(
Config
::
$items
[
'application'
][
'aliases'
][
$class
],
$class
);
return
class_alias
(
Config
::
$items
[
'application'
][
'aliases'
][
$class
],
$class
);
}
}
if
(
!
is_null
(
$path
=
$this
->
find
(
$class
)))
if
(
!
is_null
(
$path
=
static
::
find
(
$class
)))
{
{
require
$path
;
require
$path
;
$this
->
mappings
[
$class
]
=
$path
;
}
}
}
}
...
@@ -46,7 +44,7 @@ class Autoloader {
...
@@ -46,7 +44,7 @@ class Autoloader {
* @param string $class
* @param string $class
* @return string
* @return string
*/
*/
protected
function
find
(
$class
)
protected
static
function
find
(
$class
)
{
{
$file
=
str_replace
(
'\\'
,
'/'
,
$class
);
$file
=
str_replace
(
'\\'
,
'/'
,
$class
);
...
@@ -56,12 +54,12 @@ class Autoloader {
...
@@ -56,12 +54,12 @@ class Autoloader {
// library is PSR-0 compliant, and we will load it following those standards.
// library is PSR-0 compliant, and we will load it following those standards.
// This allows us to add many third-party libraries to an application and be
// This allows us to add many third-party libraries to an application and be
// able to auto-load them automatically.
// able to auto-load them automatically.
if
(
array_key_exists
(
$namespace
,
$this
->
libraries
))
if
(
array_key_exists
(
$namespace
,
static
::
$
libraries
))
{
{
return
LIBRARY_PATH
.
str_replace
(
'_'
,
'/'
,
$file
);
return
LIBRARY_PATH
.
str_replace
(
'_'
,
'/'
,
$file
);
}
}
foreach
(
$this
->
paths
as
$path
)
foreach
(
static
::
$
paths
as
$path
)
{
{
if
(
file_exists
(
$path
=
$path
.
strtolower
(
$file
)
.
EXT
))
if
(
file_exists
(
$path
=
$path
.
strtolower
(
$file
)
.
EXT
))
{
{
...
@@ -74,7 +72,7 @@ class Autoloader {
...
@@ -74,7 +72,7 @@ class Autoloader {
// libraries and load the class accordingly.
// libraries and load the class accordingly.
if
(
is_dir
(
LIBRARY_PATH
.
$namespace
))
if
(
is_dir
(
LIBRARY_PATH
.
$namespace
))
{
{
$this
->
libraries
[]
=
$namespace
;
static
::
$
libraries
[]
=
$namespace
;
return
LIBRARY_PATH
.
str_replace
(
'_'
,
'/'
,
$file
);
return
LIBRARY_PATH
.
str_replace
(
'_'
,
'/'
,
$file
);
}
}
...
...
laravel/bootstrap/core.php
View file @
c0c81083
...
@@ -16,7 +16,7 @@ IoC::bootstrap();
...
@@ -16,7 +16,7 @@ IoC::bootstrap();
$loader
=
new
Autoloader
;
$loader
=
new
Autoloader
;
spl_autoload_register
(
array
(
$loader
,
'load'
));
spl_autoload_register
(
array
(
'Laravel\\Autoloader'
,
'load'
));
function
e
(
$value
)
function
e
(
$value
)
{
{
...
...
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