Permalink
Browse files

Merge branch '2.2'

* 2.2: (70 commits)
  change wrapped exception message to be more usefull
  updated VERSION for 2.0.23
  update CONTRIBUTORS for 2.0.23
  updated CHANGELOG for 2.0.23
  [Form] fixed failing test
  [DomCrawler] added support for query string with slash
  Fixed invalid file path for hiddeninput.exe on Windows.
  fix xsd definition for strict-requirements
  [WebProfilerBundle] Fixed the toolbar styles to apply them in IE8
  [ClassLoader] fixed heredocs handling
  fixed handling of heredocs
  Add a public modifier to an interface method
  removing xdebug extension
  [HttpRequest] fixes Request::getLanguages() bug
  [HttpCache] added a test (cached content should be kept after purging)
  [DoctrineBridge] Fixed non-utf-8 recognition
  [Security] fixed HttpUtils class tests
  replaced new occurences of 'Request::create()' with '::create()'
  changed sub-requests creation to '::create()'
  fixed merge issue
  ...

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
	src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig
	src/Symfony/Component/DomCrawler/Link.php
	src/Symfony/Component/Translation/Translator.php
  • Loading branch information...
2 parents 063dc86 + a8599d5 commit 0f7c5d934fefaf17035108ed276f4792abfd606a @fabpot fabpot committed Mar 20, 2013
@@ -159,7 +159,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
$optional = true;
foreach ($tokens as $token) {
if ('variable' === $token[0]) {
- if (!$optional || !array_key_exists($token[3], $defaults) || (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
+ if (!$optional || !array_key_exists($token[3], $defaults) || null !== $mergedParams[$token[3]] && (string) $mergedParams[$token[3]] !== (string) $defaults[$token[3]]) {
// check requirement
if (null !== $this->strictRequirements && !preg_match('#^'.$token[2].'$#', $mergedParams[$token[3]])) {
$message = sprintf('Parameter "%s" for route "%s" must match "%s" ("%s" given) to generate a corresponding URL.', $token[3], $name, $token[2], $mergedParams[$token[3]]);
@@ -126,8 +126,8 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p
$node->removeAttribute('pattern');
}
- $schemes = array_filter(explode(' ', $node->getAttribute('schemes')));
- $methods = array_filter(explode(' ', $node->getAttribute('methods')));
+ $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY);
+ $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY);
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
@@ -154,8 +154,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
$type = $node->getAttribute('type');
$prefix = $node->getAttribute('prefix');
$host = $node->hasAttribute('host') ? $node->getAttribute('host') : null;
- $schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
- $methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
+ $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
+ $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
@@ -17,16 +17,6 @@
<xsd:element name="routes" type="routes" />
- <xsd:simpleType name="word">
- <xsd:restriction base="xsd:string">
- <xsd:pattern value="([a-zA-Z]){3,}"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:simpleType name="stringlist">
- <xsd:list itemType="word"/>
- </xsd:simpleType>
-
<xsd:complexType name="routes">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="import" type="import" />
@@ -49,8 +39,8 @@
<xsd:attribute name="path" type="xsd:string" />
<xsd:attribute name="pattern" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
- <xsd:attribute name="schemes" type="stringlist" />
- <xsd:attribute name="methods" type="stringlist" />
+ <xsd:attribute name="schemes" type="xsd:string" />
+ <xsd:attribute name="methods" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="import">
@@ -60,8 +50,8 @@
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="prefix" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
- <xsd:attribute name="schemes" type="stringlist" />
- <xsd:attribute name="methods" type="stringlist" />
+ <xsd:attribute name="schemes" type="xsd:string" />
+ <xsd:attribute name="methods" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="element">
View
@@ -147,7 +147,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
}
// find the first optional token
- $firstOptional = INF;
+ $firstOptional = PHP_INT_MAX;
if (!$isHost) {
for ($i = count($tokens) - 1; $i >= 0; $i--) {
$token = $tokens[$i];
@@ -4,5 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <route pattern="/test"></route>
+ <route path="/test"></route>
</routes>
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <r:route id="blog_show" pattern="/blog/{slug}" host="{_locale}.example.com">
+ <r:route id="blog_show" path="/blog/{slug}" host="{_locale}.example.com">
<r:default key="_controller">MyBundle:Blog:show</r:default>
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>
@@ -4,9 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <route id="blog_show" pattern="/blog/{slug}">
+ <route id="blog_show" path="/blog/{slug}">
<default key="_controller">MyBundle:Blog:show</default>
<requirement key="_method">GET</requirement>
- <option key="segment_separators">/</option>
<!-- </route> -->
</routes>
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <route id="blog_show" pattern="/blog/{slug}">
+ <route id="blog_show" path="/blog/{slug}">
<default key="_controller">MyBundle:Blog:show</default>
<requirement key="_method">GET</requirement>
<option key="compiler_class">RouteCompiler</option>
@@ -6,18 +6,18 @@
$collection->add('blog_show', new Route(
'/blog/{slug}',
array('_controller' => 'MyBlogBundle:Blog:show'),
- array('_method' => 'GET', 'locale' => '\w+', '_scheme' => 'https'),
+ array('locale' => '\w+'),
array('compiler_class' => 'RouteCompiler'),
- '{locale}.example.com'
+ '{locale}.example.com',
+ array('https'),
+ array('GET','POST','put','OpTiOnS')
));
$collection->add('blog_show_legacy', new Route(
'/blog/{slug}',
array('_controller' => 'MyBlogBundle:Blog:show'),
- array('locale' => '\w+'),
+ array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+',),
array('compiler_class' => 'RouteCompiler'),
- '{locale}.example.com',
- array('https'),
- array('GET')
+ '{locale}.example.com'
));
return $collection;
@@ -4,16 +4,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <route id="blog_show" path="/blog/{slug}" host="{locale}.example.com" methods="GET" schemes="https">
+ <route id="blog_show" path="/blog/{slug}" host="{locale}.example.com" methods="GET|POST put,OpTiOnS" schemes="hTTps">
<default key="_controller">MyBundle:Blog:show</default>
<requirement key="locale">\w+</requirement>
<option key="compiler_class">RouteCompiler</option>
</route>
<route id="blog_show_legacy" pattern="/blog/{slug}" host="{locale}.example.com">
<default key="_controller">MyBundle:Blog:show</default>
- <requirement key="_method">GET</requirement>
- <requirement key="_scheme">https</requirement>
+ <requirement key="_method">GET|POST|put|OpTiOnS</requirement>
+ <requirement key="_scheme">hTTps</requirement>
<requirement key="locale">\w+</requirement>
<option key="compiler_class">RouteCompiler</option>
</route>
@@ -1,17 +1,17 @@
blog_show:
path: /blog/{slug}
- defaults: { _controller: MyBlogBundle:Blog:show }
+ defaults: { _controller: "MyBundle:Blog:show" }
host: "{locale}.example.com"
requirements: { 'locale': '\w+' }
- methods: ['GET']
+ methods: ['GET','POST','put','OpTiOnS']
schemes: ['https']
options:
compiler_class: RouteCompiler
blog_show_legacy:
pattern: /blog/{slug}
- defaults: { _controller: MyBlogBundle:Blog:show }
+ defaults: { _controller: "MyBundle:Blog:show" }
host: "{locale}.example.com"
- requirements: { '_method': 'GET', 'locale': '\w+', _scheme: 'https' }
+ requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' }
options:
compiler_class: RouteCompiler
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- <import resource="validpattern.xml" prefix="/{foo}" host="{locale}.example.com">
+ <import resource="validpattern.xml" prefix="/{foo}" host="">
<default key="foo">123</default>
<requirement key="foo">\d+</requirement>
<option key="foo">bar</option>
@@ -1,7 +1,7 @@
-blog_show:
+_blog:
resource: validpattern.yml
prefix: /{foo}
defaults: { 'foo': '123' }
requirements: { 'foo': '\d+' }
options: { 'foo': 'bar' }
- host: "{locale}.example.com"
+ host: ""
@@ -286,6 +286,13 @@ public function testWithAnIntegerAsADefaultValue()
$this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo')));
}
+ public function testNullForOptionalParameterIsIgnored()
+ {
+ $routes = $this->getRoutes('test', new Route('/test/{default}', array('default' => 0)));
+
+ $this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => null)));
+ }
+
public function testQueryParamSameAsDefault()
{
$routes = $this->getRoutes('test', new Route('/test', array('default' => 'value')));
@@ -44,12 +44,12 @@ public function testLoadWithRoute()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
}
}
}
@@ -43,14 +43,16 @@ public function testLoadWithRoute()
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $route = $routes['blog_show'];
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('\w+', $route->getRequirement('locale'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+
+ foreach ($routes as $route) {
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
+ }
}
public function testLoadWithNamespacePrefix()
@@ -61,12 +63,12 @@ public function testLoadWithNamespacePrefix()
$this->assertCount(1, $routeCollection->all(), 'One route is loaded');
$route = $routeCollection->get('blog_show');
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('\w+', $route->getRequirement('slug'));
- $this->assertEquals('en|fr|de', $route->getRequirement('_locale'));
- $this->assertEquals('{_locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{_locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('slug'));
+ $this->assertSame('en|fr|de', $route->getRequirement('_locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
}
public function testLoadWithImport()
@@ -79,12 +81,11 @@ public function testLoadWithImport()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
- $this->assertEquals('MyBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
- $this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
- $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
- $this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
- $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
+ $this->assertSame('/{foo}/blog/{slug}', $route->getPath());
+ $this->assertSame('123', $route->getDefault('foo'));
+ $this->assertSame('\d+', $route->getRequirement('foo'));
+ $this->assertSame('bar', $route->getOption('foo'));
+ $this->assertSame('', $route->getHost());
}
}
@@ -73,7 +73,7 @@ public function testLoadSpecialRouteName()
$this->assertSame('/true', $route->getPath());
}
- public function testLoadWithPattern()
+ public function testLoadWithRoute()
{
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('validpattern.yml');
@@ -83,13 +83,13 @@ public function testLoadWithPattern()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('\w+', $route->getRequirement('locale'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
}
}
@@ -101,11 +101,13 @@ public function testLoadWithResource()
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
- $this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
- $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
- $this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
- $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
+
+ foreach ($routes as $route) {
+ $this->assertSame('/{foo}/blog/{slug}', $route->getPath());
+ $this->assertSame('123', $route->getDefault('foo'));
+ $this->assertSame('\d+', $route->getRequirement('foo'));
+ $this->assertSame('bar', $route->getOption('foo'));
+ $this->assertSame('', $route->getHost());
+ }
}
}

0 comments on commit 0f7c5d9

Please sign in to comment.