Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
fd42e0ca
Commit
fd42e0ca
authored
Jun 13, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved route loading into separate function.
parent
9cee4693
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
31 deletions
+49
-31
system/router.php
+49
-31
No files found.
system/router.php
View file @
fd42e0ca
...
@@ -31,39 +31,11 @@ class Router {
...
@@ -31,39 +31,11 @@ class Router {
$uri
=
(
$uri
!=
'/'
)
?
'/'
.
$uri
:
$uri
;
$uri
=
(
$uri
!=
'/'
)
?
'/'
.
$uri
:
$uri
;
// --------------------------------------------------------------
// --------------------------------------------------------------
// If a route directory is being used, load the route file
// Load the application routes.
// corresponding to the first segment of the URI.
// --------------------------------------------------------------
if
(
is_dir
(
APP_PATH
.
'routes'
))
{
if
(
$uri
==
'/'
)
{
if
(
!
file_exists
(
APP_PATH
.
'routes/home'
.
EXT
))
{
throw
new
\Exception
(
"A [home] route file is required when using a route directory."
);
}
static
::
$routes
=
require
APP_PATH
.
'routes/home'
.
EXT
;
}
else
{
$segments
=
explode
(
'/'
,
trim
(
$uri
,
'/'
));
if
(
!
file_exists
(
APP_PATH
.
'routes/'
.
$segments
[
0
]
.
EXT
))
{
throw
new
\Exception
(
"No route file defined for routes beginning with ["
.
$segments
[
0
]
.
"]"
);
}
static
::
$routes
=
require
APP_PATH
.
'routes/'
.
$segments
[
0
]
.
EXT
;
}
}
// --------------------------------------------------------------
// --------------------------------------------------------------
// If no route directory is being used, we can simply load the
if
(
is_null
(
static
::
$routes
))
// routes file from the application directory.
// --------------------------------------------------------------
else
{
{
static
::
$routes
=
require
APP_PATH
.
'routes'
.
EXT
;
static
::
$routes
=
static
::
routes
(
$uri
)
;
}
}
// --------------------------------------------------------------
// --------------------------------------------------------------
...
@@ -150,4 +122,49 @@ class Router {
...
@@ -150,4 +122,49 @@ class Router {
return
$parameters
;
return
$parameters
;
}
}
/**
* Load the routes based on the request URI.
*
* @param string $uri
* @return void
*/
private
static
function
routes
(
$uri
)
{
// --------------------------------------------------------------
// If a route directory is being used, load the route file
// corresponding to the first segment of the URI.
// --------------------------------------------------------------
if
(
is_dir
(
APP_PATH
.
'routes'
))
{
if
(
$uri
==
'/'
)
{
if
(
!
file_exists
(
APP_PATH
.
'routes/home'
.
EXT
))
{
throw
new
\Exception
(
"A [home] route file is required when using a route directory."
);
}
return
require
APP_PATH
.
'routes/home'
.
EXT
;
}
else
{
$segments
=
explode
(
'/'
,
trim
(
$uri
,
'/'
));
if
(
!
file_exists
(
APP_PATH
.
'routes/'
.
$segments
[
0
]
.
EXT
))
{
throw
new
\Exception
(
"No route file defined for routes beginning with ["
.
$segments
[
0
]
.
"]"
);
}
return
require
APP_PATH
.
'routes/'
.
$segments
[
0
]
.
EXT
;
}
}
// --------------------------------------------------------------
// If no route directory is being used, we can simply load the
// routes file from the application directory.
// --------------------------------------------------------------
else
{
return
require
APP_PATH
.
'routes'
.
EXT
;
}
}
}
}
\ 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