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
2275c746
Commit
2275c746
authored
Jul 31, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved all routing classes into routing namespace.
parent
d8eba638
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
43 deletions
+53
-43
index.php
public/index.php
+5
-3
error.php
system/error.php
+1
-1
filter.php
system/routing/filter.php
+2
-2
finder.php
system/routing/finder.php
+2
-2
loader.php
system/routing/loader.php
+33
-0
route.php
system/routing/route.php
+5
-3
router.php
system/routing/router.php
+5
-32
No files found.
public/index.php
View file @
2275c746
...
@@ -138,14 +138,16 @@ if (System\Config::get('session.driver') != '')
...
@@ -138,14 +138,16 @@ if (System\Config::get('session.driver') != '')
// --------------------------------------------------------------
// --------------------------------------------------------------
// Execute the global "before" filter.
// Execute the global "before" filter.
// --------------------------------------------------------------
// --------------------------------------------------------------
$response
=
System\Rout
e_
Filter
::
call
(
'before'
,
array
(),
true
);
$response
=
System\Rout
ing\
Filter
::
call
(
'before'
,
array
(),
true
);
// ----------------------------------------------------------
// ----------------------------------------------------------
// Execute the route function.
// Execute the route function.
// ----------------------------------------------------------
// ----------------------------------------------------------
if
(
is_null
(
$response
))
if
(
is_null
(
$response
))
{
{
$route
=
System\Router
::
make
(
System\Request
::
method
(),
System\Request
::
uri
())
->
route
();
list
(
$method
,
$uri
)
=
array
(
System\Request
::
method
(),
System\Request
::
uri
());
$route
=
System\Routing\Router
::
make
(
$method
,
$uri
,
System\Routing\Loader
::
load
(
$uri
))
->
route
();
$response
=
(
is_null
(
$route
))
?
System\Response
::
make
(
System\View
::
make
(
'error/404'
),
404
)
:
$route
->
call
();
$response
=
(
is_null
(
$route
))
?
System\Response
::
make
(
System\View
::
make
(
'error/404'
),
404
)
:
$route
->
call
();
}
}
...
@@ -157,7 +159,7 @@ else
...
@@ -157,7 +159,7 @@ else
// ----------------------------------------------------------
// ----------------------------------------------------------
// Execute the global "after" filter.
// Execute the global "after" filter.
// ----------------------------------------------------------
// ----------------------------------------------------------
System\Rout
e_
Filter
::
call
(
'after'
,
array
(
$response
));
System\Rout
ing\
Filter
::
call
(
'after'
,
array
(
$response
));
// ----------------------------------------------------------
// ----------------------------------------------------------
// Stringify the response.
// Stringify the response.
...
...
system/error.php
View file @
2275c746
...
@@ -62,7 +62,7 @@ class Error {
...
@@ -62,7 +62,7 @@ class Error {
{
{
if
(
Config
::
get
(
'error.detail'
))
if
(
Config
::
get
(
'error.detail'
))
{
{
$view
=
View
::
make
(
'exception'
)
$view
=
View
::
make
(
'e
rror/e
xception'
)
->
bind
(
'severity'
,
$severity
)
->
bind
(
'severity'
,
$severity
)
->
bind
(
'message'
,
$message
)
->
bind
(
'message'
,
$message
)
->
bind
(
'file'
,
$e
->
getFile
())
->
bind
(
'file'
,
$e
->
getFile
())
...
...
system/rout
e_
filter.php
→
system/rout
ing/
filter.php
View file @
2275c746
<?php
namespace
System
;
<?php
namespace
System
\Routing
;
class
Route_
Filter
{
class
Filter
{
/**
/**
* The loaded route filters.
* The loaded route filters.
...
...
system/rout
e_
finder.php
→
system/rout
ing/
finder.php
View file @
2275c746
<?php
namespace
System
;
<?php
namespace
System
\Routing
;
class
Route_
Finder
{
class
Finder
{
/**
/**
* All of the loaded routes.
* All of the loaded routes.
...
...
system/routing/loader.php
0 → 100644
View file @
2275c746
<?php
namespace
System\Routing
;
class
Loader
{
/**
* Load the appropriate routes for the request URI.
*
* @param string
* @return array
*/
public
static
function
load
(
$uri
)
{
$base
=
require
APP_PATH
.
'routes'
.
EXT
;
if
(
!
is_dir
(
APP_PATH
.
'routes'
)
or
$uri
==
''
)
{
return
$base
;
}
list
(
$routes
,
$segments
)
=
array
(
array
(),
explode
(
'/'
,
$uri
));
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
{
if
(
file_exists
(
$path
=
ROUTE_PATH
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
{
$routes
=
require
$path
;
}
}
return
array_merge
(
$routes
,
$base
);
}
}
\ No newline at end of file
system/route.php
→
system/rout
ing/rout
e.php
View file @
2275c746
<?php
namespace
System
;
<?php
namespace
System\Routing
;
use
System\Response
;
class
Route
{
class
Route
{
...
@@ -55,7 +57,7 @@ class Route {
...
@@ -55,7 +57,7 @@ class Route {
}
}
elseif
(
is_array
(
$this
->
callback
))
elseif
(
is_array
(
$this
->
callback
))
{
{
$response
=
isset
(
$this
->
callback
[
'before'
])
?
Route_
Filter
::
call
(
$this
->
callback
[
'before'
],
array
(),
true
)
:
null
;
$response
=
isset
(
$this
->
callback
[
'before'
])
?
Filter
::
call
(
$this
->
callback
[
'before'
],
array
(),
true
)
:
null
;
if
(
is_null
(
$response
)
and
isset
(
$this
->
callback
[
'do'
]))
if
(
is_null
(
$response
)
and
isset
(
$this
->
callback
[
'do'
]))
{
{
...
@@ -67,7 +69,7 @@ class Route {
...
@@ -67,7 +69,7 @@ class Route {
if
(
is_array
(
$this
->
callback
)
and
isset
(
$this
->
callback
[
'after'
]))
if
(
is_array
(
$this
->
callback
)
and
isset
(
$this
->
callback
[
'after'
]))
{
{
Route_
Filter
::
call
(
$this
->
callback
[
'after'
],
array
(
$response
));
Filter
::
call
(
$this
->
callback
[
'after'
],
array
(
$response
));
}
}
return
$response
;
return
$response
;
...
...
system/router.php
→
system/rout
ing/rout
er.php
View file @
2275c746
<?php
namespace
System
;
<?php
namespace
System\Routing
;
use
System\Request
;
class
Router
{
class
Router
{
...
@@ -24,13 +26,12 @@ class Router {
...
@@ -24,13 +26,12 @@ class Router {
* @param array $routes
* @param array $routes
* @return void
* @return void
*/
*/
public
function
__construct
(
$method
,
$uri
,
$routes
=
null
)
public
function
__construct
(
$method
,
$uri
,
$routes
)
{
{
// Put the request method and URI in route form. Routes begin with
// Put the request method and URI in route form. Routes begin with
// the request method and a forward slash.
// the request method and a forward slash.
$this
->
request
=
$method
.
' /'
.
trim
(
$uri
,
'/'
);
$this
->
request
=
$method
.
' /'
.
trim
(
$uri
,
'/'
);
$this
->
routes
=
$routes
;
$this
->
routes
=
(
is_array
(
$routes
))
?
$routes
:
$this
->
load
(
$uri
);
}
}
/**
/**
...
@@ -46,34 +47,6 @@ class Router {
...
@@ -46,34 +47,6 @@ class Router {
return
new
static
(
$method
,
$uri
,
$routes
);
return
new
static
(
$method
,
$uri
,
$routes
);
}
}
/**
* Load the appropriate routes for the request URI.
*
* @param string $uri
* @return array
*/
public
function
load
(
$uri
)
{
$base
=
require
APP_PATH
.
'routes'
.
EXT
;
if
(
!
is_dir
(
APP_PATH
.
'routes'
)
or
$uri
==
''
)
{
return
$base
;
}
list
(
$routes
,
$segments
)
=
array
(
array
(),
explode
(
'/'
,
$uri
));
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
{
if
(
file_exists
(
$path
=
ROUTE_PATH
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
{
$routes
=
require
$path
;
}
}
return
array_merge
(
$routes
,
$base
);
}
/**
/**
* Search a set of routes for the route matching a method and URI.
* Search a set of routes for the route matching a method and URI.
*
*
...
...
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