Commit Graph

11906 Commits

Author SHA1 Message Date
Eric GELOEN
97f6a1b4d9 [Form] Update password type trimming to false 2012-11-16 14:51:56 +01:00
Julien 'ruian' Galenski
83b37ffb4d [DependencyInjection] Return self for add...
Bug fix: no
Feature addition: no
Backwards compatibility break: yes
Symfony2 tests pass: yes
License of the code: MIT

Return self instance when call an ADD something method.
2012-11-16 14:35:03 +01:00
Fabien Potencier
e3f8d2db33 merged branch Tobion/collection-hostname (PR #6018)
This PR was squashed before being merged into the master branch (closes #6018).

Commits
-------

6334343 [Routing] removed getHostnamePattern from RouteCollection

Discussion
----------

[Routing] removed getHostnamePattern from RouteCollection

this method is not useful and can introduce inconsistencies when a sub-route has a different hostname, which already has a getter for the hostname
2012-11-15 19:30:36 +01:00
Tobias Schultze
6334343cda [Routing] removed getHostnamePattern from RouteCollection 2012-11-15 19:30:36 +01:00
Sebastiaan Stok
f2cbea3b30 [Security] remove escape charters from username provided by Digest DigestAuthenticationListener 2012-11-15 16:54:04 +01:00
Thomas Tourlourat
82334d2640 Force loader to be null or a EntityLoaderInterface 2012-11-15 16:44:00 +01:00
Sebastiaan Stok
80f6992a41 [Security] added test extra for digest authentication 2012-11-15 16:42:03 +01:00
Sebastiaan Stok
d66b03c830 fixed CS 2012-11-15 16:42:02 +01:00
Vincent Simonin
694697dd91 [Security] Fixed digest authentication
Digest authentication fail if digest parameters contains `=` character or `, ` string.

* Support escaped characters
2012-11-15 16:42:02 +01:00
Vincent Simonin
c067586368 [Security] Fixed digest authentication
Digest authentication fail if digest parameters contains `=` character or `, ` string.
2012-11-15 16:42:01 +01:00
Fabien Potencier
9a2edb9a63 merged branch lolautruche/httpCacheStoreExtendable (PR #6016)
This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes #6016).

Commits
-------

9b0cad4 Added HttpCache\Store::generateContentDigest() + changed  visibility

Discussion
----------

Added HttpCache\Store::generateContentDigest() + changed $root visibility

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
License of the code: MIT
Documentation PR: -

## Description
This PR adds 2 small changes in base `HttpCache\Store`:

1. Adds `generateContentDigest()` protected method, allowing to easily override the default behavior for special cases.
2. Change `$root` visibility to *protected* to let descendant access it.

This allows special implementations of HttpCache when storing specific cache files in a different place is needed.

## Example
An example of implementation can be found [in eZ Publish 5 source code](https://github.com/ezsystems/ezp-next/blob/master/eZ/Publish/Core/MVC/Symfony/Cache/Http/LocationAwareStore.php). In this example, eZ Publish content cache entities are stored under a different folder than regular cache entities in order to ease cache purge based on a content location.

## Testing
No unit tests were added since the behavior didn't change and the new method is protected.

PS : It would be nice to have this in 2.1 branch as well 😃
2012-11-15 14:23:01 +01:00
Jérôme Vieilledent
d2920c94a1 Added HttpCache\Store::generateContentDigest() + changed visibility 2012-11-15 14:23:00 +01:00
Victor Berchet
32dc31eceb [SecurityBundle] Convert Http method to uppercase in the config 2012-11-15 08:13:39 +01:00
Fabien Potencier
225e3e53d4 merged branch vicb/acceptheaderfix (PR #6003)
This PR was merged into the master branch.

Commits
-------

f4b630d [HttpFoundation] fix #6002

Discussion
----------

[HttpFoundation] fix #6002

---------------------------------------------------------------------------

by fabpot at 2012-11-13T17:02:45Z

Can you add a test?

---------------------------------------------------------------------------

by Tobion at 2012-11-13T17:04:23Z

hehe see #6004 there is also a test

---------------------------------------------------------------------------

by vicb at 2012-11-13T17:05:06Z

There is a test in the original PR, no need for 6004.

---------------------------------------------------------------------------

by vicb at 2012-11-13T17:05:20Z

Which is why is was failing btw

---------------------------------------------------------------------------

by Tobion at 2012-11-13T17:06:36Z

The test in 6002 did not fail for me without your patch.

---------------------------------------------------------------------------

by fabpot at 2012-11-14T12:47:46Z

@Tobion @vicb What do we do? Just revert #6002 or merge this PR?

---------------------------------------------------------------------------

by vicb at 2012-11-14T13:25:51Z

Merge. Go go go :)

----- Reply message -----
De : "Fabien Potencier" <notifications@github.com>
Pour : "symfony/symfony" <symfony@noreply.github.com>
Cc : "Victor Berchet" <victor@suumit.com>
Objet : [symfony] [HttpFoundation] fix #6002 (#6003)
Date : mer., nov. 14, 2012 13:47
@Tobion @vicb What do we do? Just revert #6002 or merge this PR?

&mdash;

Reply to this email directly or view it on GitHub.

---------------------------------------------------------------------------

by Tobion at 2012-11-14T13:31:22Z

@vicb can you explain what it fixes? As I said, your test does not cover something that would fail without the patch. So I don't see the bug.

---------------------------------------------------------------------------

by vicb at 2012-11-14T15:30:55Z

@Tobion php.net states: The `current()` function simply returns the value of the array element that's currently being pointed to by the internal pointer and `reset()` returns the value of the first array element.

I have no clue what the "element that's currently being pointed to by the internal pointer" in this method so `reset()` is probably what you want.

Validated ?

---------------------------------------------------------------------------

by Tobion at 2012-11-14T16:12:03Z

I agree `reset()` is more explicit here. But `current()` should work just as well in this case because the array pointer can only be at the first item when calling the method. Anyway, this is good to merge. I just hoped there was a unit test that ensures this on my machine. This is why I added the test in my patch. Maybe Fabien can just merge the second commit on #6004

---------------------------------------------------------------------------

by vicb at 2012-11-14T16:20:57Z

As explained in #6004, there is already a test from my first PR that made Travis go red.
2012-11-14 17:48:15 +01:00
Fabien Potencier
2c346cba07 merged branch fabpot/images (PR #6006)
This PR was merged into the master branch.

Commits
-------

9f1cd84 moved most static assets directly into the templates

Discussion
----------

moved most static assets directly into the templates

This has been done for several reasons:

 * for consistency with the way we already manage the WDT and the
   profiler icons;
 * it makes the Exception independent from the location of the assets
   (and from the asset() function)
 * this is the second step to make the WebProfiler useable outside the
   full-stack framework

see dbcd171dd3

---------------------------------------------------------------------------

by stof at 2012-11-13T17:52:39Z

the images blue_picto_more and blue_picto_less are also used in DoctrineBundle (and probably in JMSDebuggingBundle but I haven't checked). Could you submit a PR inlining the images too before removing them ?

---------------------------------------------------------------------------

by fabpot at 2012-11-13T18:02:18Z

Any image useful for other bundles should not be deleted. So, if DoctrineBundle is using the blue_pico_* images, I'm going to revert their deletion.

---------------------------------------------------------------------------

by schmittjoh at 2012-11-13T18:07:02Z

I'm using them in two bundles, JMSDebuggingBundle and JMSJobQueueBundle (same for the exception related templates).

---------------------------------------------------------------------------

by dlsniper at 2012-11-13T22:22:29Z

Wouldn't it be better to have the encoded icons in a separate CSS file as different classes/background images?

---------------------------------------------------------------------------

by fabpot at 2012-11-14T11:28:24Z

ok, I've reverted the removal of the images that might be useful in third-party bundles.
2012-11-14 13:48:11 +01:00
Fabien Potencier
9f1cd84844 moved most static assets directly into the templates
This has been done for several reasons:

 * for consistency with the way we already manage the WDT and the
   profiler icons;
 * it makes the Exception independent from the location of the assets
   (and from the asset() function)
 * this is the second step to make the WebProfiler useable outside the
   full-stack framework

see dbcd171dd3
2012-11-14 12:26:15 +01:00
Fabien Potencier
777aa5085d merged branch Tobion/hostname-serialize (PR #6008)
This PR was merged into the master branch.

Commits
-------

c865220 [Routing] fix missing hostname serialization in Route

Discussion
----------

[Routing] fix missing hostname serialization in Route
2012-11-14 07:11:14 +01:00
Tobias Schultze
c865220267 [Routing] fix missing hostname serialization in Route 2012-11-14 00:25:56 +01:00
Victor Berchet
f4b630d1e0 [HttpFoundation] fix #6002 2012-11-13 17:57:35 +01:00
Fabien Potencier
7bfe13c912 merged branch vicb/acceptheader (PR #6002)
This PR was merged into the master branch.

Commits
-------

395c004 [HttpFoundation] Fix AcceptHeader

Discussion
----------

[HttpFoundation] Fix AcceptHeader

The important lines are:

```php
<?php
-        return !empty($this->items) ? current($this->items) : null;
+        return !empty($this->items) ? $this->items[0] : null;
```

(and the corresponding test).

The commit has some code re-org to make reading tests easier (providers defined close the the corresponding test). This might be personal preferences only, let me know if it should be reverted.
2012-11-13 17:35:27 +01:00
Fabien Potencier
ecb963be27 Merge branch '2.1'
* 2.1:
  fixed comment. The parent ACL is not accessed in this method.
  [HttpFoundation] Make host & methods really case insensitive in the RequestMacther
  [Validator] fixed Ukrainian language code (closes #5972)
  Fixed case of php function
2012-11-13 17:29:48 +01:00
Fabien Potencier
2d488b79f2 Merge branch '2.0' into 2.1
* 2.0:
  fixed comment. The parent ACL is not accessed in this method.
  [HttpFoundation] Make host & methods really case insensitive in the RequestMacther
  [Validator] fixed Ukrainian language code (closes #5972)
  Fixed case of php function

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.uk.xliff
	src/Symfony/Component/HttpFoundation/RequestMatcher.php
2012-11-13 17:29:06 +01:00
Victor Berchet
395c00487c [HttpFoundation] Fix AcceptHeader 2012-11-13 17:18:54 +01:00
Fabien Potencier
b126664406 Merge branch '2.1'
* 2.1: (24 commits)
  forced Travis to use source to workaround their not-up-to-date Composer on PHP 5.3.3
  [Routing] removed irrelevant string cast in Route
  Fixed typo
  Make YamlFileLoader and XmlFileLoader file loading extensible
  [HttpKernel] fix typo
  Fixed singularization of "prices"
  [Form] Removed an exception that prevented valid formats from being passed, e.g. "h" for the hour, "L" for the month etc.
  [HttpKernel] fixed Client when using StreamedResponses (closes #5370)
  fixed PDO session handler for Oracle (closes #5829)
  [HttpFoundation] fixed PDO session handler for Oracle (closes #5829)
  [Locale] removed a check that is done too early (and it is done twice anyways)
  Update src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf
  Adding new localized strings for farsi validation.
  [HttpFoundation] moved the HTTP protocol check from StreamedResponse to Response (closes #5937)
  [Form] Fixed forms not to be marked invalid if their children are already marked invalid
  [Form] Excluded some tests in NumberToLocalizedStringTransformerTest which fail on ICU 4.4, but work on ICU 4.8
  added missing tests from previous merge
  [Form] Fixed NumberToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible
  Fix export-ignore on Windows
  Show correct class name InputArgument in error message
  ...

Conflicts:
	.travis.yml
	src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php
2012-11-13 15:08:04 +01:00
Fabien Potencier
2fa9bd0b3f forced Travis to use source to workaround their not-up-to-date Composer on PHP 5.3.3 2012-11-13 15:04:20 +01:00
Fabien Potencier
83de4c2b02 merged branch fabpot/public-resources (PR #6000)
This PR was merged into the master branch.

Commits
-------

0159358 refactored CSS, images, templates included in the built-in bundles
812b9b1 replace _ in stylesheets (ids and classes) by - (should be consistent across the whole framework now)
983b2b5 uniformized styles
e0aab40 renamed sf-exceptionreset to sf-reset

Discussion
----------

Public resources refactoring

The first 3 commits are just cosmetic ones.

The last one refactors CSS, images, and templates included in the built-in bundles. Right now, everything is tied to the exception pages, but the code can be used standalone.

So, the goal is to make things more decoupled and more reusable across different bundles. That way, a bundle can provide pages that look like the other ones in Symfony without the need to duplicate code.

See the associated PR for the distribution bundle to see an example.

If you want to have a look at the last commit (not sure if it is worth it), you probably want to append ?w=1 to the URL to avoid too much whitespace noise.

---------------------------------------------------------------------------

by pborreli at 2012-11-13T09:38:00Z

congrats ! #6000

---------------------------------------------------------------------------

by fabpot at 2012-11-13T09:38:39Z

A simple usage example:

```jinja
{% extends "TwigBundle::layout.html.twig" %}

{% block body %}
    <div class="block">
        FOOBAR
    </div>
{% endblock %}
```
2012-11-13 14:20:12 +01:00
Fabien Potencier
d45a76b316 merged branch Inori/consistent-util-classes (PR #5879)
This PR was squashed before being merged into the master branch (closes #5879).

Commits
-------

07bd5c6 Make non-instantiable utils classes consistent with each other

Discussion
----------

Make non-instantiable utils classes consistent with each other

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

As per discussion in #5875 turned out that we don't have a consistent way to define non-instantiatable classes.

I don't like `final` as it removes flexibility with no visible gain.
I don't like `abstract` since it's not specifically clear what is meant by that. Is this class not complete? Should it be extended?
2012-11-13 13:58:15 +01:00
Roman Marintsenko
07bd5c6306 Make non-instantiable utils classes consistent with each other 2012-11-13 13:58:14 +01:00
Fabien Potencier
cb00411fc8 merged branch Jola/comment-fix (PR #5992)
This PR was merged into the 2.0 branch.

Commits
-------

b3a8efd fixed comment. The parent ACL is not accessed in this method.

Discussion
----------

fixed comment. The parent ACL is not accessed in this method.

Just fixed a comment on PermissionGrantingStrategy.
hasSufficientPermissions() is not accessing the parent ACL. That's done in isGranted().
2012-11-13 13:50:22 +01:00
Fabien Potencier
15fd24e46d merged branch Tobion/routing-phpdoc (PR #5994)
This PR was merged into the master branch.

Commits
-------

50e41d2 one space too much
5d9a36f small fix and enhancement
1e1cb13 [Routing] added more phpdoc and  replaced 'array of type' by 'Type[]'

Discussion
----------

[Routing] added more phpdoc and  replaced 'array of type' by 'Type[]'

---------------------------------------------------------------------------

by Tobion at 2012-11-12T17:03:01Z

@fabpot you should squash with your great merging tool ;)
2012-11-13 13:49:27 +01:00
Fabien Potencier
7b4a27893a merged branch Tobion/patch-2 (PR #5997)
This PR was merged into the 2.1 branch.

Commits
-------

7569ee2 [Routing] removed irrelevant string cast in Route

Discussion
----------

[Routing] removed irrelevant string cast in Route

Even if the passed key is an integer, casting to string won't make any difference in array keys (it remains an int key).
2012-11-13 13:49:04 +01:00
Fabien Potencier
0159358a08 refactored CSS, images, templates included in the built-in bundles
The goal is to make things more decoupled and more reusable across
different bundles.

There will be a PR for the distribution bundle too to simplify the code
based on this PR.
2012-11-13 10:20:48 +01:00
Fabien Potencier
812b9b1724 replace _ in stylesheets (ids and classes) by - (should be consistent across the whole framework now) 2012-11-12 18:32:01 +01:00
Fabien Potencier
983b2b5e2a uniformized styles 2012-11-12 18:19:16 +01:00
Fabien Potencier
e0aab4075f renamed sf-exceptionreset to sf-reset 2012-11-12 18:19:16 +01:00
Fabien Potencier
ff9051d19f [TwigBundle] fixed typo 2012-11-12 18:18:57 +01:00
Tobias Schultze
50e41d2c5c one space too much 2012-11-12 18:02:08 +01:00
Tobias Schultze
5d9a36fe42 small fix and enhancement 2012-11-12 18:00:02 +01:00
Tobias Schultze
7569ee2964 [Routing] removed irrelevant string cast in Route
Even if the passed key is an integer, casting to string won't make any difference in array keys (it remains an int key).
2012-11-12 17:54:27 +01:00
Tobias Schultze
1e1cb13faf [Routing] added more phpdoc and replaced 'array of type' by 'Type[]' 2012-11-12 16:14:50 +01:00
Fabien Potencier
226743f8cf merged branch fabpot/code-helpers (PR #5986)
This PR was merged into the master branch.

Commits
-------

56fe8d1 duplicated the code helper code to the Twig bundle

Discussion
----------

moved code helper code to the Twig bundle

These helpers are very specific and are only used in TwigBundle for the
profiler and the exception templates.

---------------------------------------------------------------------------

by schmittjoh at 2012-11-12T09:12:56Z

Is there a reason for this BC break other than a cosmetical tweak?

If not strictly necessary, I'd like to see these kind of changes being scheduled for 3.0.

---------------------------------------------------------------------------

by fabpot at 2012-11-12T09:29:35Z

Of course, I don't want to make this change without a reason and indeed, I forgot to mention the why of this change. Let me explain.

I've been working on the integration of the Symfony web profiler into other OSS that use HttpKernel like Silex and Drupal for quite some time now. That's why I developed the new namespace feature in Twig, that's why I've refactored the web profiler to only use Twig and not the templating component. One of the last step is this PR, which reduces the number of dependencies to be able to use the WebProfiler bundle.

So, this change is not cosmetic, but one more step towards the goal of making the web profiler more reusable.

---------------------------------------------------------------------------

by schmittjoh at 2012-11-12T13:22:28Z

I see, makes sense. How about duplicating the code for now?

After looking through the history, it doesn't seem like it changes often
(the last real code change was a year ago). So, it should not be much more
maintenance effort, and we could keep BC here.

On Mon, Nov 12, 2012 at 10:29 AM, Fabien Potencier <notifications@github.com
> wrote:

> Of course, I don't want to make this change without a reason and indeed, I
> forgot to mention the why of this change. Let me explain.
>
> I've been working on the integration of the Symfony web profiler into
> other OSS that use HttpKernel like Silex and Drupal for quite some time
> now. That's why I developed the new namespace feature in Twig, that's why
> I've refactored the web profiler to only use Twig and not the templating
> component. One of the last step is this PR, which reduces the number of
> dependencies to be able to use the WebProfiler bundle.
>
> So, this change is not cosmetic, but one more step towards the goal of
> making the web profiler more reusable.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/symfony/symfony/pull/5986#issuecomment-10281201>.
>
>

---------------------------------------------------------------------------

by fabpot at 2012-11-12T13:32:33Z

Of course, that's a possibility. But what for? I doubt that people are using this code. Are you using this code somewhere?

---------------------------------------------------------------------------

by schmittjoh at 2012-11-12T13:37:24Z

Yes, I believe that I'm using it both in JMSDebuggingBundle, and
JMSJobQueueBundle as both are rendering exception stack traces at some
point.

On Mon, Nov 12, 2012 at 2:32 PM, Fabien Potencier
<notifications@github.com>wrote:

> Of course, that's a possibility. But what for? I doubt that people are
> using this code. Are you using this code somewhere?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/symfony/symfony/pull/5986#issuecomment-10287353>.
>
>

---------------------------------------------------------------------------

by fabpot at 2012-11-12T14:11:50Z

ok, fair enough. The code is now in the framework bundle as well.
2012-11-12 15:15:24 +01:00
Fabien Potencier
56fe8d1ffd duplicated the code helper code to the Twig bundle
The code has been duplicated and not moved for BC reasons.

This code has been duplicated in the Twig bundle to be able to decouple
the web profiler and the exception templates.
2012-11-12 15:07:56 +01:00
Fabien Potencier
938670d34b merged branch jdreesen/patch-1 (PR #5991)
This PR was merged into the 2.1 branch.

Commits
-------

3881649 Fixed typo

Discussion
----------

Fixed typo

Fixed a small typo in the docblock
2012-11-12 15:04:21 +01:00
Jörn Lang
b3a8efd6cd fixed comment. The parent ACL is not accessed in this method. 2012-11-12 15:01:47 +01:00
Jacob Dreesen
3881649477 Fixed typo
Fixed a small typo in the docblock
2012-11-12 14:58:31 +01:00
Fabien Potencier
d060fd4953 merged branch vicb/security (PR #5988)
This PR was merged into the 2.0 branch.

Commits
-------

e12bd12 [HttpFoundation] Make host & methods really case insensitive in the RequestMacther

Discussion
----------

[HttpFoundation] Make host & methods really case insensitive in the Requ...

...estMacther

and backport changes from 2.2

Details:
- does not take case into account when checking the host (the `Request` always returns a lowercase value) to protect against user typo,
- makes the constructor case proof by invoking setters rather than setting properties directly (you could then add un unreachable method i.e; `get`)

Please propagate to 2.1/2.2 if accpeted. Thanks.
2012-11-12 14:56:10 +01:00
Fabien Potencier
966053069d [HttpKernel] fixed some unit tests 2012-11-12 14:30:42 +01:00
Fabien Potencier
c94bdf6bdf merged branch arnaud-lb/hostname-routes (PR #3378)
This PR was merged into the master branch.

Commits
-------

17f51a1 Merge pull request #6 from Tobion/hostname-routes
e120a7a fix API of RouteCollection
26e5684 some type fixes
514e27a [Routing] fix PhpMatcherDumper that returned numeric-indexed params that are returned besides named placeholders by preg_match
7ed3013 switch to array_replace instead of array_merge
94ec653 removed irrelevant string case in XmlFileLoader
9ffe3de synchronize the fixtures in different formats and fix default for numeric requirement
6cd3457 fixed CS
8366b8a [Routing] fixed validity check for hostname params in UrlGenerator
a8ce621 [Routing] added support for hostname in the apache matcher dumper
562174a [Routing] fixed indentation of dumped collections
1489021 fixed CS
a270458 [Routing] added some more unit tests
153fcf2 [Routing] added some unit tests for the PHP loader
68da6ad [Routing] added support for hostname in the XML loader
3dfca47 [Routing] added some unit tests for the YAML loader
92f9c15 [Routing] changed CompiledRoute signature to be more consistent
d91e5a2 [Routing] fixed Route annotation for hostname (should be hostname_pattern instead of hostnamePattern)
62de881 [Routing] clarified a variable content
11b4378 [Routing] added hostname support in UrlMatcher
fc015d5 [Routing] fixed route generation with a hostname pattern when the hostname is the same as the current one (no need to force the generated URL to be absolute)
462999d [Routing] display hostname pattern in router:debug output
805806a [Routing] added hostname matching support to UrlGenerator
7a15e00 [Routing] added hostname matching support to AnnotationClassLoader
cab450c [Routing] added hostname matching support to YamlFileLoader
85d11af [Routing] added hostname matching support to PhpMatcherDumper
402359b [Routing] added hostname matching support to RouteCompiler
add3658 [Routing] added hostname matching support to Route and RouteCollection
23feb37 [Routing] added hostname matching support to CompiledRoute

Discussion
----------

[2.2][Routing] hostname pattern for routes

Bug fix: no
Feature addition: yes
Fixes the following tickets: #1762, #3276
Backwards compatibility break: no
Symfony2 tests pass: yes

This adds a hostname_pattern property to routes. It works like the pattern property (hostname_pattern can have variables, requirements, etc). The hostname_pattern property can be set on both routes and route collections.

Yaml example:

``` yaml
# Setting the hostname_pattern for a whole collection of routes

AcmeBundle:
    resource: "@AcmeBundle/Controller/"
    type: annotation
    prefix: /
    hostname_pattern: {locale}.example.com
    requirements:
        locale: en|fr

# Setting the hostname_pattern for single route

some_route:
    pattern: /hello/{name}
    hostname_pattern: {locale}.example.com
    requirements:
        locale: en|fr
        name: \w+
    defaults:
        _controller: Foo:bar:baz
```

Annotations example:

``` php
<?php

/**
 * Inherits requirements and hostname pattern from the collection
 * @Route("/foo")
 */
public function fooAction();

/**
 * Set a specific hostnamePattern for this route only
 * @Route("/foo", hostnamePattern="{_locale}.example.com", requirements={"_locale="fr|en"})
 */
public function fooAction();

```

Performance:

Consecutive routes with the same hostname pattern are grouped, and a single test is made against the hostname for this group, so the overhead is very low:

```
@Route("/foo", hostnamePattern="a.example.com")
@Route("/bar", hostnamePattern="a.example.com")
@Route("/baz", hostnamePattern="b.example.com")
```

is compiled like this:

```
if (hostname matches a.example.com) {
    // test route "/foo"
    // test route "/bar"
}
if (hostname matches b.example.com) {
    // test route "/baz"
}
```

The PR also tries harder to optimize routes sharing the same prefix:

```
@Route("/cafe")
@Route("/cacao")
@Route("/coca")
```

is compiled like this:

```
if (url starts with /c) {
    if (url starts with /ca) {
        // test route "/cafe"
        // test route "/cacao"
    }
    // test route "/coca"
}
```

---------------------------------------------------------------------------

by Koc at 2012-02-16T14:14:19Z

Interesting. Have you looked at #3057, #3002?

Killer feature of #3057 : multiple hostnames per route.

---------------------------------------------------------------------------

by arnaud-lb at 2012-02-16T14:21:28Z

@Koc yes, the main difference is that this PR allows variables in the hostname pattern, with requirements, etc just like the path pattern. The other PRs use a `_host` requirement, which works like the `_method` requirement (takes a list of allowed hostnames separated by `|`).

> Killer feature of #3057 : multiple hostnames per route.

If you have multiple tlds you can easily do it like this:

``` yaml
hostbased_route:
  pattern:  /
  hostname_pattern: symfony.{tld}
  requirements:
     tld: org|com
```

Or with completely different domain names:

``` yaml
hostbased_route:
  pattern:  /
  hostname_pattern: {domain}
  requirements:
     domain: example\.com|symfony\.com
```

Requirements allow DIC %parameters%, so you can also put you domains in your config.yml.

---------------------------------------------------------------------------

by Koc at 2012-02-16T15:52:16Z

wow, nice! So looks like this PR closes my #3276 ticket?

---------------------------------------------------------------------------

by arnaud-lb at 2012-02-16T15:53:55Z

Yes, apparently :)

---------------------------------------------------------------------------

by Koc at 2012-02-16T15:56:53Z

I cann't find method `ParameterBag::resolveValue` calling in this PR, like here https://github.com/symfony/symfony/pull/3316/files

---------------------------------------------------------------------------

by arnaud-lb at 2012-02-16T16:03:48Z

I think it's in core already

---------------------------------------------------------------------------

by Koc at 2012-02-16T16:11:38Z

looks like yes
https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php#L81

---------------------------------------------------------------------------

by dlsniper at 2012-02-16T19:37:57Z

This PR looks great, it's something like this I've been waiting for.

I know @fabpot said he's working on something similar but I think if he agrees with this it could be a great addition to the core.

@fabpot , @stof any objections about this PR if gets fully done?

---------------------------------------------------------------------------

by stof at 2012-02-16T20:00:21Z

Well, we already have 2 other implementations for this stuff in the PRs. @fabpot please take time to look at them

---------------------------------------------------------------------------

by stof at 2012-02-16T20:03:17Z

This one is absolutely not tested and seems to break the existing tests according to the description. So it cannot be reviewed as is.

---------------------------------------------------------------------------

by dlsniper at 2012-02-16T22:00:24Z

@stof I understand it's a WIP but the other PRs where ignored as well and like you've said, there's a bunch of PRs already on this issue all doing a thing or another. So an early feedback on this, or any other, could lead it to the right path in order to finally solve this issue.

---------------------------------------------------------------------------

by arnaud-lb at 2012-02-17T23:57:28Z

Added tests; others are passing now

---------------------------------------------------------------------------

by arnaud-lb at 2012-02-22T21:10:20Z

I'm going to add support for the Apache dumper and the XML loader; does this PR have a chance to be merged ? cc @fabpot @stof

---------------------------------------------------------------------------

by stof at 2012-02-22T22:05:23Z

@arnaud-lb We need to wait @fabpot's mind about the way he prefers to implement it to know which one can be merged.

---------------------------------------------------------------------------

by IjinPL at 2012-02-27T02:01:57Z

Forked @arnaud-lb *hostname_pattern* to add XML parasing support.

---------------------------------------------------------------------------

by stof at 2012-04-03T23:59:12Z

@arnaud-lb Please rebase your branch. It conflicts with master because of the move of the tests

@fabpot @vicb ping

---------------------------------------------------------------------------

by dlsniper at 2012-04-13T19:52:23Z

Hi,

If @arnaud-lb won't be able to rebase this I could help with some work on this but there's still the problem of actually choosing the right PR(s) for this issue. @blogsh says in his last commit that this PR is a bit better in his opinion but @fabpot needs to decide in the end.

---------------------------------------------------------------------------

by arnaud-lb at 2012-04-14T17:26:55Z

@stof rebased

---------------------------------------------------------------------------

by nomack84 at 2012-04-20T13:01:00Z

@fabpot Any final word about this pull request? It would be nice to have this feature ready for 2.1.

---------------------------------------------------------------------------

by asm89 at 2012-04-24T21:27:50Z

Using the `{_locale}` placeholder in the host would set the locale for the request just like it does now?

Another thing I'm wondering is how/if it should be possible to set the hostname pattern for all your routes, or at least when importing routes? Otherwise you'll end up repeating the same host pattern over and over again. I think this is also important when importing routes from third party bundles.

---------------------------------------------------------------------------

by fabpot at 2012-04-25T01:17:51Z

I'm reviewing this PR and I'm going to make some modifications. I will send a PR to @arnaud-lb soon.

---------------------------------------------------------------------------

by fabpot at 2012-04-25T03:10:18Z

I've sent a PR to @arnaud-lb arnaud-lb/symfony#3 that fixes some minor bugs and add support in more classes.

---------------------------------------------------------------------------

by fabpot at 2012-04-25T03:12:52Z

@asm89:

Placeholders in the hostname are managed in the same way as the ones from the URL pattern.

You can set a hostname pattern for a collection (like the prefix for URL patterns).

---------------------------------------------------------------------------

by Tobion at 2012-04-25T09:31:19Z

I think we need to change the contents of $variables, $tokens, and $hostnameTokens in the CompiledRoute. They contain redundant information and the content structure of these variables ist not documentation in any way. If we remove duplicated content and put it in a (single) well defined variable, it would also reduce the information that need to be saved in the generated class by the UrlGeneratorDumper.

---------------------------------------------------------------------------

by arnaud-lb at 2012-04-26T08:54:21Z

@fabpot thanks :) I've merged it

---------------------------------------------------------------------------

by stof at 2012-04-26T12:08:40Z

A rebase is needed

---------------------------------------------------------------------------

by fabpot at 2012-04-26T13:28:08Z

no need to rebase, I will resolve the conflicts when merging. I've still have some minor changes to do before merging though. Anyone willing to have a look at implementing the Apache dumper part?

---------------------------------------------------------------------------

by Tobion at 2012-04-26T14:59:00Z

@fabpot you want to merge this for 2.1 although it introduces big changes that need extensive review and testing? But #3958 is not considered for 2.1? I thought we are in some sort of feature freeze for the components in order to not postpone the release.

---------------------------------------------------------------------------

by fabpot at 2012-04-26T17:21:09Z

@Tobion: I never said it will be in 2.1. The plan is to create a 2.1 branch soon so that we can continue working on 2.2.

---------------------------------------------------------------------------

by Koc at 2012-04-26T19:46:43Z

https://twitter.com/#!/fabpot/status/178502663690915840
2012-11-12 14:20:01 +01:00
Victor Berchet
e12bd123be [HttpFoundation] Make host & methods really case insensitive in the RequestMacther
and backport changes from 2.2
2012-11-12 13:39:12 +01:00
Arnaud Le Blanc
17f51a1873 Merge pull request #6 from Tobion/hostname-routes
fix API of RouteCollection
2012-11-12 04:09:53 -08:00