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
7f6ca57b
Commit
7f6ca57b
authored
Sep 10, 2013
by
Dave Marshall
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use RequestStack if available
parent
466beac0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
src/Silex/Application.php
src/Silex/Application.php
+11
-2
src/Silex/EventListener/LocaleListener.php
src/Silex/EventListener/LocaleListener.php
+3
-2
No files found.
src/Silex/Application.php
View file @
7f6ca57b
...
...
@@ -23,6 +23,7 @@ use Symfony\Component\HttpKernel\EventListener\RouterListener;
use
Symfony\Component\HttpKernel\Exception\HttpException
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\RequestStack
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
...
...
@@ -92,8 +93,8 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
$urlMatcher
=
new
LazyUrlMatcher
(
function
()
use
(
$app
)
{
return
$app
[
'url_matcher'
];
});
$dispatcher
->
addSubscriber
(
new
RouterListener
(
$urlMatcher
,
$app
[
'request_context'
],
$app
[
'logger'
]));
$dispatcher
->
addSubscriber
(
new
LocaleListener
(
$app
,
$urlMatcher
));
$dispatcher
->
addSubscriber
(
new
RouterListener
(
$urlMatcher
,
$app
[
'request_context'
],
$app
[
'logger'
]
,
$app
[
'request_stack'
]
));
$dispatcher
->
addSubscriber
(
new
LocaleListener
(
$app
,
$urlMatcher
,
$app
[
'request_stack'
]
));
if
(
isset
(
$app
[
'exception_handler'
]))
{
$dispatcher
->
addSubscriber
(
$app
[
'exception_handler'
]);
}
...
...
@@ -113,6 +114,14 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
return
new
HttpKernel
(
$app
[
'dispatcher'
],
$app
[
'resolver'
]);
});
$this
[
'request_stack'
]
=
$this
->
share
(
function
()
use
(
$app
)
{
if
(
class_exists
(
"Symfony\Component\HttpFoundation\RequestStack"
))
{
return
new
RequestStack
();
}
return
null
;
});
$this
[
'request_context'
]
=
$this
->
share
(
function
()
use
(
$app
)
{
$context
=
new
RequestContext
();
...
...
src/Silex/EventListener/LocaleListener.php
View file @
7f6ca57b
...
...
@@ -13,6 +13,7 @@ namespace Silex\EventListener;
use
Symfony\Component\HttpKernel\Event\GetResponseEvent
;
use
Symfony\Component\HttpKernel\EventListener\LocaleListener
as
BaseLocaleListener
;
use
Symfony\Component\HttpFoundation\RequestStack
;
use
Symfony\Component\Routing\RequestContextAwareInterface
;
use
Silex\Application
;
...
...
@@ -25,9 +26,9 @@ class LocaleListener extends BaseLocaleListener
{
protected
$app
;
public
function
__construct
(
Application
$app
,
RequestContextAwareInterface
$router
=
null
)
public
function
__construct
(
Application
$app
,
RequestContextAwareInterface
$router
=
null
,
RequestStack
$requestStack
=
null
)
{
parent
::
__construct
(
$app
[
'locale'
],
$router
);
parent
::
__construct
(
$app
[
'locale'
],
$router
,
$requestStack
);
$this
->
app
=
$app
;
}
...
...
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