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
c2fa4cba
Commit
c2fa4cba
authored
Nov 02, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restricted the HTTP fragment service provider to Symfony 2.4+
parent
44883022
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
src/Silex/Provider/HttpFragmentServiceProvider.php
src/Silex/Provider/HttpFragmentServiceProvider.php
+7
-8
tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php
.../Silex/Tests/Provider/HttpFragmentServiceProviderTest.php
+4
-0
No files found.
src/Silex/Provider/HttpFragmentServiceProvider.php
View file @
c2fa4cba
...
...
@@ -23,21 +23,20 @@ use Symfony\Component\HttpKernel\UriSigner;
/**
* HttpKernel Fragment integration for Silex.
*
* This service provider requires Symfony 2.4+.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class
HttpFragmentServiceProvider
implements
ServiceProviderInterface
{
public
function
register
(
Application
$app
)
{
$app
[
'fragment.handler'
]
=
$app
->
share
(
function
(
$app
)
{
$handler
=
new
FragmentHandler
(
$app
[
'fragment.renderers'
],
$app
[
'debug'
],
$app
[
'request_stack'
]);
if
(
!
class_exists
(
'Symfony\Component\HttpFoundation\RequestStack'
))
{
throw
new
\LogicException
(
'The HTTP Fragment service provider only works with Symfony 2.4+.'
);
}
// to be removed when 2.3 is not supported anymore
if
(
null
===
$app
[
'request_stack'
])
{
$handler
->
setRequest
(
$app
[
'request'
]);
}
return
$handler
;
$app
[
'fragment.handler'
]
=
$app
->
share
(
function
(
$app
)
{
return
new
FragmentHandler
(
$app
[
'fragment.renderers'
],
$app
[
'debug'
],
$app
[
'request_stack'
]);
});
$app
[
'fragment.renderer.inline'
]
=
$app
->
share
(
function
(
$app
)
{
...
...
tests/Silex/Tests/Provider/HttpFragmentServiceProviderTest.php
View file @
c2fa4cba
...
...
@@ -21,6 +21,10 @@ class HttpFragmentServiceProviderTest extends \PHPUnit_Framework_TestCase
{
public
function
testRenderFunction
()
{
if
(
!
class_exists
(
'Symfony\Component\HttpFoundation\RequestStack'
))
{
$this
->
markTestSkipped
(
'HttpFragmentServiceProvider is not available on Symfony <2.4'
);
}
$app
=
new
Application
();
$app
->
register
(
new
HttpFragmentServiceProvider
());
...
...
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