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
43aee48f
Commit
43aee48f
authored
Aug 03, 2015
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed auto-generated route names when there is a conflict
parent
e98dd5f7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+2
-1
tests/Silex/Tests/ControllerCollectionTest.php
tests/Silex/Tests/ControllerCollectionTest.php
+6
-5
No files found.
src/Silex/ControllerCollection.php
View file @
43aee48f
...
@@ -208,8 +208,9 @@ class ControllerCollection
...
@@ -208,8 +208,9 @@ class ControllerCollection
$controller
->
getRoute
()
->
setPath
(
$prefix
.
$controller
->
getRoute
()
->
getPath
());
$controller
->
getRoute
()
->
setPath
(
$prefix
.
$controller
->
getRoute
()
->
getPath
());
if
(
!
$name
=
$controller
->
getRouteName
())
{
if
(
!
$name
=
$controller
->
getRouteName
())
{
$name
=
$controller
->
generateRouteName
(
''
);
$name
=
$controller
->
generateRouteName
(
''
);
$i
=
0
;
while
(
$routes
->
get
(
$name
))
{
while
(
$routes
->
get
(
$name
))
{
$name
.=
'_'
;
$name
=
$controller
->
generateRouteName
(
''
)
.
'_'
.++
$i
;
}
}
$controller
->
bind
(
$name
);
$controller
->
bind
(
$name
);
}
}
...
...
tests/Silex/Tests/ControllerCollectionTest.php
View file @
43aee48f
...
@@ -71,7 +71,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -71,7 +71,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$mountedRootController
=
$controllers
->
match
(
'/'
,
function
()
{});
$mountedRootController
=
$controllers
->
match
(
'/'
,
function
()
{});
$mainRootController
=
new
Controller
(
new
Route
(
'/'
));
$mainRootController
=
new
Controller
(
new
Route
(
'/'
));
$mainRootController
->
bind
(
$mainRootController
->
generateRouteName
(
'main_'
));
$mainRootController
->
bind
(
$mainRootController
->
generateRouteName
(
'main_
1
'
));
$controllers
->
flush
();
$controllers
->
flush
();
...
@@ -84,11 +84,12 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -84,11 +84,12 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$controllers
->
match
(
'/a-a'
,
function
()
{});
$controllers
->
match
(
'/a-a'
,
function
()
{});
$controllers
->
match
(
'/a_a'
,
function
()
{});
$controllers
->
match
(
'/a_a'
,
function
()
{});
$controllers
->
match
(
'/a/a'
,
function
()
{});
$routes
=
$controllers
->
flush
();
$routes
=
$controllers
->
flush
();
$this
->
assertCount
(
2
,
$routes
->
all
());
$this
->
assertCount
(
3
,
$routes
->
all
());
$this
->
assertEquals
(
array
(
'_a_a'
,
'_a_a_'
),
array_keys
(
$routes
->
all
()));
$this
->
assertEquals
(
array
(
'_a_a'
,
'_a_a_
1'
,
'_a_a_2
'
),
array_keys
(
$routes
->
all
()));
}
}
public
function
testUniqueGeneratedRouteNamesAmongMounts
()
public
function
testUniqueGeneratedRouteNamesAmongMounts
()
...
@@ -104,7 +105,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -104,7 +105,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$routes
=
$controllers
->
flush
();
$routes
=
$controllers
->
flush
();
$this
->
assertCount
(
2
,
$routes
->
all
());
$this
->
assertCount
(
2
,
$routes
->
all
());
$this
->
assertEquals
(
array
(
'_root_a_leaf'
,
'_root_a_leaf_'
),
array_keys
(
$routes
->
all
()));
$this
->
assertEquals
(
array
(
'_root_a_leaf'
,
'_root_a_leaf_
1
'
),
array_keys
(
$routes
->
all
()));
}
}
public
function
testUniqueGeneratedRouteNamesAmongNestedMounts
()
public
function
testUniqueGeneratedRouteNamesAmongNestedMounts
()
...
@@ -123,7 +124,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -123,7 +124,7 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$routes
=
$controllers
->
flush
();
$routes
=
$controllers
->
flush
();
$this
->
assertCount
(
2
,
$routes
->
all
());
$this
->
assertCount
(
2
,
$routes
->
all
());
$this
->
assertEquals
(
array
(
'_root_a_tree_leaf'
,
'_root_a_tree_leaf_'
),
array_keys
(
$routes
->
all
()));
$this
->
assertEquals
(
array
(
'_root_a_tree_leaf'
,
'_root_a_tree_leaf_
1
'
),
array_keys
(
$routes
->
all
()));
}
}
public
function
testAssert
()
public
function
testAssert
()
...
...
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