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
e40faa19
Commit
e40faa19
authored
Aug 03, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed application file structure and routing definitions.
parent
32f38320
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
28 deletions
+16
-28
filters.php
application/routes/filters.php
+0
-0
routes.php
application/routes/routes.php
+0
-0
composers.php
application/views/composers.php
+0
-0
index.php
public/index.php
+2
-2
loader.php
system/routing/loader.php
+13
-25
view.php
system/view.php
+1
-1
No files found.
application/filters.php
→
application/
routes/
filters.php
View file @
e40faa19
File moved
application/routes.php
→
application/routes
/routes
.php
View file @
e40faa19
File moved
application/composers.php
→
application/
views/
composers.php
View file @
e40faa19
File moved
public/index.php
View file @
e40faa19
...
@@ -158,7 +158,7 @@ require SYS_PATH.'routing/filter'.EXT;
...
@@ -158,7 +158,7 @@ require SYS_PATH.'routing/filter'.EXT;
// --------------------------------------------------------------
// --------------------------------------------------------------
// Register the route filters.
// Register the route filters.
// --------------------------------------------------------------
// --------------------------------------------------------------
System\Routing\Filter
::
register
(
require
APP
_PATH
.
'filters'
.
EXT
);
System\Routing\Filter
::
register
(
require
ROUTE
_PATH
.
'filters'
.
EXT
);
// --------------------------------------------------------------
// --------------------------------------------------------------
// Execute the global "before" filter.
// Execute the global "before" filter.
...
@@ -170,7 +170,7 @@ $response = System\Routing\Filter::call('before', array(), true);
...
@@ -170,7 +170,7 @@ $response = System\Routing\Filter::call('before', array(), true);
// ----------------------------------------------------------
// ----------------------------------------------------------
if
(
is_null
(
$response
))
if
(
is_null
(
$response
))
{
{
$route
=
System\Routing\Router
::
make
(
System\Request
::
method
(),
System\Request
::
uri
(),
new
System\Routing\Loader
(
APP
_PATH
))
->
route
();
$route
=
System\Routing\Router
::
make
(
System\Request
::
method
(),
System\Request
::
uri
(),
new
System\Routing\Loader
(
ROUTE
_PATH
))
->
route
();
$response
=
(
is_null
(
$route
))
?
System\Response
::
error
(
'404'
)
:
$route
->
call
();
$response
=
(
is_null
(
$route
))
?
System\Response
::
error
(
'404'
)
:
$route
->
call
();
}
}
...
...
system/routing/loader.php
View file @
e40faa19
...
@@ -35,14 +35,7 @@ class Loader {
...
@@ -35,14 +35,7 @@ class Loader {
*/
*/
public
function
load
(
$uri
)
public
function
load
(
$uri
)
{
{
$base
=
require
$this
->
path
.
'routes'
.
EXT
;
return
array_merge
(
$this
->
load_nested_routes
(
$uri
),
require
$this
->
path
.
'routes'
.
EXT
);
if
(
!
is_dir
(
$this
->
path
.
'routes'
)
or
$uri
==
''
)
{
return
$base
;
}
return
array_merge
(
$this
->
load_nested_routes
(
$uri
),
$base
);
}
}
/**
/**
...
@@ -56,12 +49,12 @@ class Loader {
...
@@ -56,12 +49,12 @@ class Loader {
$segments
=
explode
(
'/'
,
$uri
);
$segments
=
explode
(
'/'
,
$uri
);
// Work backwards through the URI segments until we find the deepest possible
// Work backwards through the URI segments until we find the deepest possible
// matching route
file in the routes directory
.
// matching route
directory. Once we find it, we will return those routes
.
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
{
{
if
(
file_exists
(
$path
=
$this
->
path
.
'routes/'
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
if
(
is_dir
(
$path
=
$this
->
path
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
))
{
{
return
require
$path
;
return
require
$path
.
'/routes'
.
EXT
;
}
}
}
}
...
@@ -78,28 +71,23 @@ class Loader {
...
@@ -78,28 +71,23 @@ class Loader {
* @param string $path
* @param string $path
* @return array
* @return array
*/
*/
public
static
function
all
(
$reload
=
false
,
$path
=
null
)
public
static
function
all
(
$reload
=
false
,
$path
=
ROUTE_PATH
)
{
{
if
(
!
is_null
(
static
::
$routes
)
and
!
$reload
)
return
static
::
$routes
;
if
(
!
is_null
(
static
::
$routes
)
and
!
$reload
)
return
static
::
$routes
;
if
(
is_null
(
$path
))
$path
=
APP_PATH
;
$routes
=
require
$path
.
'routes'
.
EXT
;
$routes
=
require
$path
.
'routes'
.
EXT
;
if
(
is_dir
(
$path
.
'routes'
))
// Since route files can be nested deep within the route directory, we need to
{
// recursively spin through the directory to find every file.
// Since route files can be nested deep within the route directory, we need to
$directoryIterator
=
new
\RecursiveDirectoryIterator
(
$path
);
// recursively spin through the directory to find every file.
$directoryIterator
=
new
\RecursiveDirectoryIterator
(
$path
.
'routes'
);
$recursiveIterator
=
new
\RecursiveIteratorIterator
(
$directoryIterator
,
\RecursiveIteratorIterator
::
SELF_FIRST
);
$recursiveIterator
=
new
\RecursiveIteratorIterator
(
$directoryIterator
,
\RecursiveIteratorIterator
::
SELF_FIRST
);
foreach
(
$recursiveIterator
as
$file
)
foreach
(
$recursiveIterator
as
$file
)
{
if
(
filetype
(
$file
)
===
'file'
and
strpos
(
$file
,
EXT
)
!==
false
and
strpos
(
$file
,
'filters'
.
EXT
)
===
false
)
{
{
if
(
filetype
(
$file
)
===
'file'
and
strpos
(
$file
,
EXT
)
!==
false
)
$routes
=
array_merge
(
require
$file
,
$routes
);
{
$routes
=
array_merge
(
require
$file
,
$routes
);
}
}
}
}
}
...
...
system/view.php
View file @
e40faa19
...
@@ -61,7 +61,7 @@ class View {
...
@@ -61,7 +61,7 @@ class View {
{
{
if
(
is_null
(
static
::
$composers
))
if
(
is_null
(
static
::
$composers
))
{
{
static
::
$composers
=
require
APP
_PATH
.
'composers'
.
EXT
;
static
::
$composers
=
require
VIEW
_PATH
.
'composers'
.
EXT
;
}
}
$instance
=
new
static
(
$view
,
$data
);
$instance
=
new
static
(
$view
,
$data
);
...
...
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