diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index a5c351aa28..066d1f3c82 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -96,6 +96,7 @@ class Configuration
->canBeUnset()
->scalarNode('cache_warmer')->end()
->scalarNode('resource')->isRequired()->end()
+ ->scalarNode('type')->end()
->end()
;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 4331c10cbf..5590bf058b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -234,6 +234,10 @@ class FrameworkExtension extends Extension
$container->setParameter('routing.resource', $config['resource']);
+ if (isset($config['type'])) {
+ $container->setParameter('router.options.resource_type', $config['type']);
+ }
+
if (isset($config['cache_warmer']) && $config['cache_warmer']) {
$container->getDefinition('router.cache_warmer')->addTag('kernel.cache_warmer');
$container->setAlias('router', 'router.cached');
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
index 65ff4e29b0..c75ca9aa9d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
@@ -22,6 +22,7 @@
Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer
%kernel.name%%kernel.environment%UrlMatcher
%kernel.name%%kernel.environment%UrlGenerator
+
@@ -71,6 +72,7 @@
%router.options.matcher_base_class%
%router.options.matcher_dumper_class%
%router.options.matcher.cache_class%
+ %router.options.resource_type%
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index 07c0dc20c5..4a635a758e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -63,8 +63,9 @@
-
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
index 20a272c4c7..7439b4dc9f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php
@@ -13,8 +13,9 @@ $container->loadFromExtension('app', 'config', array(
'only_exceptions' => true,
),
'router' => array(
- 'resource' => '%kernel.root_dir%/config/routing.xml',
'cache_warmer' => true,
+ 'resource' => '%kernel.root_dir%/config/routing.xml',
+ 'type' => 'xml',
),
'session' => array(
'auto_start' => true,
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
index ebc2f39fe6..8c508d98e2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml
@@ -10,7 +10,7 @@
-
+
loader.foo
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
index bb8d3bc3bc..74571b6e6d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml
@@ -8,8 +8,9 @@ app.config:
profiler:
only_exceptions: true
router:
- resource: %kernel.root_dir%/config/routing.xml
cache_warmer: true
+ resource: %kernel.root_dir%/config/routing.xml
+ type: xml
session:
auto_start: true
class: Session
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 99da686fa3..95d7d21dec 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -51,6 +51,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->hasDefinition('router.real'), '->registerRouterConfiguration() loads routing.xml');
$this->assertEquals($container->getParameter('kernel.root_dir').'/config/routing.xml', $container->getParameter('routing.resource'), '->registerRouterConfiguration() sets routing resource');
+ $this->assertEquals('xml', $container->getParameter('router.options.resource_type'), '->registerRouterConfiguration() sets routing resource type');
$this->assertTrue($container->getDefinition('router.cache_warmer')->hasTag('kernel.cache_warmer'), '->registerRouterConfiguration() tags router cache warmer if cache warming is set');
$this->assertEquals('router.cached', (string) $container->getAlias('router'), '->registerRouterConfiguration() changes router alias to cached if cache warming is set');
}
diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php
index cc90ee8dc1..1a39019abd 100644
--- a/src/Symfony/Component/Routing/Router.php
+++ b/src/Symfony/Component/Routing/Router.php
@@ -35,8 +35,9 @@ class Router implements RouterInterface
*
* Available options:
*
- * * cache_dir: The cache directory (or null to disable caching)
- * * debug: Whether to enable debugging or not (false by default)
+ * * cache_dir: The cache directory (or null to disable caching)
+ * * debug: Whether to enable debugging or not (false by default)
+ * * resource_type: Type hint for the main resource (optional)
*
* @param LoaderInterface $loader A LoaderInterface instance
* @param mixed $resource The main resource to load
@@ -63,6 +64,7 @@ class Router implements RouterInterface
'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper',
'matcher_cache_class' => 'ProjectUrlMatcher',
+ 'resource_type' => null,
);
// check option names
@@ -81,7 +83,7 @@ class Router implements RouterInterface
public function getRouteCollection()
{
if (null === $this->collection) {
- $this->collection = $this->loader->load($this->resource);
+ $this->collection = $this->loader->load($this->resource, $this->options['resource_type']);
}
return $this->collection;