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
5aa6a974
Commit
5aa6a974
authored
Mar 25, 2011
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor {routeCollection => routes}, {controllerCollection => controllers}
parent
f10043eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
40 deletions
+40
-40
src/Silex/Application.php
src/Silex/Application.php
+9
-9
src/Silex/ControllerCollection.php
src/Silex/ControllerCollection.php
+4
-4
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+7
-7
tests/Silex/Tests/ControllerCollectionTest.php
tests/Silex/Tests/ControllerCollectionTest.php
+17
-17
tests/Silex/Tests/FunctionalTest.php
tests/Silex/Tests/FunctionalTest.php
+3
-3
No files found.
src/Silex/Application.php
View file @
5aa6a974
...
...
@@ -36,8 +36,8 @@ use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
class
Application
extends
HttpKernel
implements
EventSubscriberInterface
{
private
$dispatcher
;
private
$route
Collection
;
private
$controller
Collection
;
private
$route
s
;
private
$controller
s
;
private
$request
;
/**
...
...
@@ -45,8 +45,8 @@ class Application extends HttpKernel implements EventSubscriberInterface
*/
public
function
__construct
()
{
$this
->
route
Collection
=
new
RouteCollection
();
$this
->
controller
Collection
=
new
ControllerCollection
(
$this
->
routeCollection
);
$this
->
route
s
=
new
RouteCollection
();
$this
->
controller
s
=
new
ControllerCollection
(
$this
->
routes
);
$this
->
dispatcher
=
new
EventDispatcher
();
$this
->
dispatcher
->
addSubscriber
(
$this
);
...
...
@@ -74,7 +74,7 @@ class Application extends HttpKernel implements EventSubscriberInterface
*/
public
function
getRouteCollection
()
{
return
$this
->
route
Collection
;
return
$this
->
route
s
;
}
/**
...
...
@@ -99,7 +99,7 @@ class Application extends HttpKernel implements EventSubscriberInterface
$route
=
new
Route
(
$pattern
,
array
(
'_controller'
=>
$to
),
$requirements
);
$controller
=
new
Controller
(
$route
);
$this
->
controller
Collection
->
add
(
$controller
);
$this
->
controller
s
->
add
(
$controller
);
return
$controller
;
}
...
...
@@ -230,7 +230,7 @@ class Application extends HttpKernel implements EventSubscriberInterface
*/
public
function
flush
()
{
$this
->
controller
Collection
->
flush
();
$this
->
controller
s
->
flush
();
}
/**
...
...
@@ -254,9 +254,9 @@ class Application extends HttpKernel implements EventSubscriberInterface
{
$this
->
request
=
$event
->
getRequest
();
$this
->
controller
Collection
->
flush
();
$this
->
controller
s
->
flush
();
$matcher
=
new
UrlMatcher
(
$this
->
route
Collection
,
array
(
$matcher
=
new
UrlMatcher
(
$this
->
route
s
,
array
(
'base_url'
=>
$this
->
request
->
getBaseUrl
(),
'method'
=>
$this
->
request
->
getMethod
(),
'host'
=>
$this
->
request
->
getHost
(),
...
...
src/Silex/ControllerCollection.php
View file @
5aa6a974
...
...
@@ -25,11 +25,11 @@ use Symfony\Component\Routing\RouteCollection;
class
ControllerCollection
{
private
$controllers
=
array
();
private
$route
Collection
;
private
$route
s
;
public
function
__construct
(
RouteCollection
$route
Collection
)
public
function
__construct
(
RouteCollection
$route
s
)
{
$this
->
route
Collection
=
$routeCollection
;
$this
->
route
s
=
$routes
;
}
/**
...
...
@@ -48,7 +48,7 @@ class ControllerCollection
public
function
flush
()
{
foreach
(
$this
->
controllers
as
$controller
)
{
$this
->
route
Collection
->
add
(
$controller
->
getRouteName
(),
$controller
->
getRoute
());
$this
->
route
s
->
add
(
$controller
->
getRouteName
(),
$controller
->
getRoute
());
$controller
->
freeze
();
}
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
5aa6a974
...
...
@@ -74,9 +74,9 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
{
$application
=
new
Application
();
$route
Collection
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\RouteCollection'
,
$route
Collection
);
$this
->
assertEquals
(
0
,
count
(
$route
Collection
->
all
()));
$route
s
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\RouteCollection'
,
$route
s
);
$this
->
assertEquals
(
0
,
count
(
$route
s
->
all
()));
}
public
function
testGetRouteCollectionWithRoutes
()
...
...
@@ -91,10 +91,10 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
return
'bar'
;
});
$route
Collection
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\RouteCollection'
,
$route
Collection
);
$this
->
assertEquals
(
0
,
count
(
$route
Collection
->
all
()));
$route
s
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\RouteCollection'
,
$route
s
);
$this
->
assertEquals
(
0
,
count
(
$route
s
->
all
()));
$application
->
flush
();
$this
->
assertEquals
(
2
,
count
(
$route
Collection
->
all
()));
$this
->
assertEquals
(
2
,
count
(
$route
s
->
all
()));
}
}
tests/Silex/Tests/ControllerCollectionTest.php
View file @
5aa6a974
...
...
@@ -28,40 +28,40 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
{
public
function
testGetRouteCollectionWithNoRoutes
()
{
$route
Collection
=
new
RouteCollection
();
$controller
Collection
=
new
ControllerCollection
(
$routeCollection
);
$route
s
=
new
RouteCollection
();
$controller
s
=
new
ControllerCollection
(
$routes
);
$this
->
assertEquals
(
0
,
count
(
$route
Collection
->
all
()));
$controller
Collection
->
flush
();
$this
->
assertEquals
(
0
,
count
(
$route
Collection
->
all
()));
$this
->
assertEquals
(
0
,
count
(
$route
s
->
all
()));
$controller
s
->
flush
();
$this
->
assertEquals
(
0
,
count
(
$route
s
->
all
()));
}
public
function
testGetRouteCollectionWithRoutes
()
{
$route
Collection
=
new
RouteCollection
();
$controller
Collection
=
new
ControllerCollection
(
$routeCollection
);
$controller
Collection
->
add
(
new
Controller
(
new
Route
(
'/foo'
)));
$controller
Collection
->
add
(
new
Controller
(
new
Route
(
'/bar'
)));
$route
s
=
new
RouteCollection
();
$controller
s
=
new
ControllerCollection
(
$routes
);
$controller
s
->
add
(
new
Controller
(
new
Route
(
'/foo'
)));
$controller
s
->
add
(
new
Controller
(
new
Route
(
'/bar'
)));
$this
->
assertEquals
(
0
,
count
(
$route
Collection
->
all
()));
$controller
Collection
->
flush
();
$this
->
assertEquals
(
2
,
count
(
$route
Collection
->
all
()));
$this
->
assertEquals
(
0
,
count
(
$route
s
->
all
()));
$controller
s
->
flush
();
$this
->
assertEquals
(
2
,
count
(
$route
s
->
all
()));
}
public
function
testControllerFreezing
()
{
$route
Collection
=
new
RouteCollection
();
$controller
Collection
=
new
ControllerCollection
(
$routeCollection
);
$route
s
=
new
RouteCollection
();
$controller
s
=
new
ControllerCollection
(
$routes
);
$fooController
=
new
Controller
(
new
Route
(
'/foo'
));
$fooController
->
setRouteName
(
'foo'
);
$controller
Collection
->
add
(
$fooController
);
$controller
s
->
add
(
$fooController
);
$barController
=
new
Controller
(
new
Route
(
'/bar'
));
$barController
->
setRouteName
(
'bar'
);
$controller
Collection
->
add
(
$barController
);
$controller
s
->
add
(
$barController
);
$controller
Collection
->
flush
();
$controller
s
->
flush
();
try
{
$fooController
->
setRouteName
(
'foo2'
);
...
...
tests/Silex/Tests/FunctionalTest.php
View file @
5aa6a974
...
...
@@ -35,8 +35,8 @@ class FunctionalTest extends \PHPUnit_Framework_TestCase
->
setRouteName
(
'foo_abc'
);
$application
->
flush
();
$route
Collection
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\Route'
,
$route
Collection
->
get
(
'homepage'
));
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\Route'
,
$route
Collection
->
get
(
'foo_abc'
));
$route
s
=
$application
->
getRouteCollection
();
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\Route'
,
$route
s
->
get
(
'homepage'
));
$this
->
assertInstanceOf
(
'Symfony\Component\Routing\Route'
,
$route
s
->
get
(
'foo_abc'
));
}
}
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