Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
74372712
Commit
74372712
authored
Aug 08, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made the default route name binding as late as possible
parent
fb31ac4d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
3 deletions
+6
-3
src/Silex/Controller.php
src/Silex/Controller.php
+2
-3
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+3
-0
tests/Silex/Tests/ControllerTest.php
tests/Silex/Tests/ControllerTest.php
+1
-0
No files found.
src/Silex/Controller.php
View file @
74372712
...
...
@@ -34,7 +34,6 @@ class Controller
public
function
__construct
(
Route
$route
)
{
$this
->
route
=
$route
;
$this
->
bind
(
$this
->
defaultRouteName
());
}
/**
...
...
@@ -140,7 +139,7 @@ class Controller
$this
->
isFrozen
=
true
;
}
p
rivate
function
d
efaultRouteName
()
p
ublic
function
bindD
efaultRouteName
()
{
$requirements
=
$this
->
route
->
getRequirements
();
$method
=
isset
(
$requirements
[
'_method'
])
?
$requirements
[
'_method'
]
:
''
;
...
...
@@ -149,6 +148,6 @@ class Controller
$routeName
=
str_replace
(
array
(
'/'
,
':'
,
'|'
,
'-'
),
'_'
,
$routeName
);
$routeName
=
preg_replace
(
'/[^a-z0-9A-Z_.]+/'
,
''
,
$routeName
);
return
$routeName
;
$this
->
routeName
=
$routeName
;
}
}
src/Silex/ControllerCollection.php
View file @
74372712
...
...
@@ -48,6 +48,9 @@ class ControllerCollection
public
function
flush
()
{
foreach
(
$this
->
controllers
as
$controller
)
{
if
(
!
$controller
->
getRouteName
())
{
$controller
->
bindDefaultRouteName
();
}
$this
->
routes
->
add
(
$controller
->
getRouteName
(),
$controller
->
getRoute
());
$controller
->
freeze
();
}
...
...
tests/Silex/Tests/ControllerTest.php
View file @
74372712
...
...
@@ -75,6 +75,7 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
public
function
testDefaultRouteNameGeneration
(
Route
$route
,
$expectedRouteName
)
{
$controller
=
new
Controller
(
$route
);
$controller
->
bindDefaultRouteName
();
$this
->
assertEquals
(
$expectedRouteName
,
$controller
->
getRouteName
());
}
...
...
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