Commit c2fa4cba authored by Fabien Potencier's avatar Fabien Potencier

restricted the HTTP fragment service provider to Symfony 2.4+

parent 44883022
...@@ -23,21 +23,20 @@ use Symfony\Component\HttpKernel\UriSigner; ...@@ -23,21 +23,20 @@ use Symfony\Component\HttpKernel\UriSigner;
/** /**
* HttpKernel Fragment integration for Silex. * HttpKernel Fragment integration for Silex.
* *
* This service provider requires Symfony 2.4+.
*
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class HttpFragmentServiceProvider implements ServiceProviderInterface class HttpFragmentServiceProvider implements ServiceProviderInterface
{ {
public function register(Application $app) public function register(Application $app)
{ {
$app['fragment.handler'] = $app->share(function ($app) { if (!class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
$handler = new FragmentHandler($app['fragment.renderers'], $app['debug'], $app['request_stack']); 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) { $app['fragment.renderer.inline'] = $app->share(function ($app) {
......
...@@ -21,6 +21,10 @@ class HttpFragmentServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -21,6 +21,10 @@ class HttpFragmentServiceProviderTest extends \PHPUnit_Framework_TestCase
{ {
public function testRenderFunction() public function testRenderFunction()
{ {
if (!class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
$this->markTestSkipped('HttpFragmentServiceProvider is not available on Symfony <2.4');
}
$app = new Application(); $app = new Application();
$app->register(new HttpFragmentServiceProvider()); $app->register(new HttpFragmentServiceProvider());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment