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
38541655
Commit
38541655
authored
Nov 10, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring autoloader.
parent
fe218f9b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
autoloader.php
laravel/autoloader.php
+22
-17
No files found.
laravel/autoloader.php
View file @
38541655
...
@@ -54,7 +54,7 @@ class Autoloader {
...
@@ -54,7 +54,7 @@ class Autoloader {
{
{
// After PHP namespaces were introduced, most libaries ditched underscores for
// After PHP namespaces were introduced, most libaries ditched underscores for
// for namespaces to indicate the class directory hierarchy. We will check for
// for namespaces to indicate the class directory hierarchy. We will check for
// the presen
t
of namespace slashes to determine the directory separator.
// the presen
ce
of namespace slashes to determine the directory separator.
$separator
=
(
strpos
(
$class
,
'\\'
)
!==
false
)
?
'\\'
:
'_'
;
$separator
=
(
strpos
(
$class
,
'\\'
)
!==
false
)
?
'\\'
:
'_'
;
$library
=
substr
(
$class
,
0
,
strpos
(
$class
,
$separator
));
$library
=
substr
(
$class
,
0
,
strpos
(
$class
,
$separator
));
...
@@ -66,12 +66,31 @@ class Autoloader {
...
@@ -66,12 +66,31 @@ class Autoloader {
// namespaces and underscores indicate the directory hierarchy of the class.
// namespaces and underscores indicate the directory hierarchy of the class.
if
(
isset
(
static
::
$libraries
[
$library
]))
if
(
isset
(
static
::
$libraries
[
$library
]))
{
{
return
str_replace
(
'_'
,
'/'
,
$file
)
.
EXT
;
return
LIBRARY_PATH
.
str_replace
(
'_'
,
'/'
,
$file
)
.
EXT
;
}
}
// Since not all controllers will be resolved by the controller resolver,
// we will do a quick check in the controller directory for the class.
// For instance, since base controllers would not be resolved by the
// controller class, we will need to resolve them here.
if
(
strpos
(
$class
,
'_Controller'
)
!==
false
)
{
$controller
=
str_replace
(
array
(
'_Controller'
,
'_'
),
array
(
''
,
'/'
),
$class
);
if
(
file_exists
(
$path
=
strtolower
(
CONTROLLER_PATH
.
$controller
.
EXT
)))
{
return
$path
;
}
}
// Next we will search through the common Laravel paths for the class file.
// The Laravel framework path, along with the libraries and models paths
// will be searched according to the Laravel class naming standard.
$lower
=
strtolower
(
$file
);
foreach
(
static
::
$paths
as
$path
)
foreach
(
static
::
$paths
as
$path
)
{
{
if
(
file_exists
(
$path
=
$path
.
strtolower
(
$file
)
.
EXT
))
if
(
file_exists
(
$path
=
$path
.
$lower
.
EXT
))
{
{
return
$path
;
return
$path
;
}
}
...
@@ -86,20 +105,6 @@ class Autoloader {
...
@@ -86,20 +105,6 @@ class Autoloader {
return
$path
;
return
$path
;
}
}
// Since not all controllers will be resolved by the controller resolver,
// we will do a quick check in the controller directory for the class.
// For instance, since base controllers would not be resolved by the
// controller class, we will need to resolve them here.
if
(
strpos
(
$class
,
'_Controller'
)
!==
false
)
{
$controller
=
str_replace
(
array
(
'_Controller'
,
'_'
),
array
(
''
,
'/'
),
$class
);
if
(
file_exists
(
$path
=
strtolower
(
CONTROLLER_PATH
.
$controller
.
EXT
)))
{
return
$path
;
}
}
}
}
}
}
\ No newline at end of file
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