From 255d42830da6b08fad6e36a7f7c409c31a5b12ed Mon Sep 17 00:00:00 2001
From: Jordi Boggiano <j.boggiano@seld.be>
Date: Fri, 3 May 2013 16:26:16 +0200
Subject: [PATCH] Allow sf2.3, fix scope issue

---
 Extractor/ApiDocExtractor.php |  2 +-
 Tests/WebTestCase.php         | 10 +++++++++-
 composer.json                 |  6 +++---
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php
index 1293726..bc96273 100644
--- a/Extractor/ApiDocExtractor.php
+++ b/Extractor/ApiDocExtractor.php
@@ -180,7 +180,7 @@ class ApiDocExtractor
             $method = $matches[2];
             if ($this->container->has($controller)) {
                 $this->container->enterScope('request');
-                $this->container->set('request', new Request());
+                $this->container->set('request', new Request(), 'request');
                 $class = get_class($this->container->get($controller));
                 $this->container->leaveScope('request');
             }
diff --git a/Tests/WebTestCase.php b/Tests/WebTestCase.php
index f6387f3..b2cd8ce 100644
--- a/Tests/WebTestCase.php
+++ b/Tests/WebTestCase.php
@@ -14,6 +14,7 @@ namespace Nelmio\ApiDocBundle\Tests;
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
 use Symfony\Component\Filesystem\Filesystem;
 use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\DependencyInjection\Scope;
 
 abstract class WebTestCase extends BaseWebTestCase
 {
@@ -43,7 +44,14 @@ abstract class WebTestCase extends BaseWebTestCase
         }
         static::$kernel->boot();
 
-        return static::$kernel->getContainer();
+        $container = static::$kernel->getContainer();
+
+        // add request scope if not created (for forward compat with sf2.3)
+        if (!$container->hasScope('request')) {
+            $container->addScope(new Scope('request'));
+        }
+
+        return $container;
     }
 
     protected static function getKernelClass()
diff --git a/composer.json b/composer.json
index ed81f81..7d03918 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
         }
     ],
     "require": {
-        "symfony/framework-bundle": "~2.1,<2.3-dev",
+        "symfony/framework-bundle": "~2.1",
         "symfony/twig-bundle": "~2.1",
         "symfony/form": "~2.1",
         "dflydev/markdown": "1.0.*"
@@ -28,9 +28,9 @@
         "symfony/browser-kit": "~2.1",
         "symfony/validator": "~2.1",
         "symfony/yaml": "~2.1",
-        "friendsofsymfony/rest-bundle": "dev-master",
+        "friendsofsymfony/rest-bundle": "0.12.*@dev",
         "jms/serializer-bundle": ">=0.11",
-        "sensio/framework-extra-bundle": "dev-master"
+        "sensio/framework-extra-bundle": "~2.1"
     },
     "minimum-stability": "dev",
     "autoload": {