Commit Graph

5710 Commits

Author SHA1 Message Date
Victor Berchet
2cf7136e53 [FrameworkBundle][Form] tweak the choice widget PHP template 2011-06-23 15:07:20 +02:00
Fabien Potencier
482492625d [Validator] restricted the True and False validator accepted values (the notion of True/False in PHP alone is too large) 2011-06-23 08:49:04 +02:00
Fabien Potencier
8ccebc4631 [DomCrawler] fixed Link::getUri() method for anchors 2011-06-23 08:20:13 +02:00
Fabien Potencier
88c8119152 merged branch asm89/domcrawler_link (PR #1410)
Commits
-------

d49e306 [DomCrawler] Fixed handling of relative query strings as links
a4451b4 [DomCrawler] Added tests for links starting with ?foo

Discussion
----------

[DomCrawler] Fixed handling of relative query strings as links

The link object concatenates links containing only a query string to the current URI. This shouldn't happen if the current URI already contains a query string.

This PR fixes the incorrect behavior (tests included).
2011-06-23 08:09:00 +02:00
Fabien Potencier
6de97c56e1 [Form] made required part of the algorithm to determine if an empty value should be added to a choice 2011-06-23 07:56:13 +02:00
Fabien Potencier
a395582605 merged branch stloyd/choicetype (PR #1371)
Commits
-------

7783a05 Removed unused code from DateType Additional tests for ChoiceType and DateType based code
cdd39ac Added ability to set "empty_value" for `DateTimeType`, `DateType` and `TimeType` Additional tests covering added code
af4a7d7 More tests and more compatible code, with some suggestions from @helmer
527b738 Test covered version of fix for issue #1336

Discussion
----------

[Form] Added ability to set "empty_value" for choice list

Hey,

This PR is similar to #1336, but this one is fully test covered and have few change in behavior:

- if choice field is not set as non-required, `empty_value` is not added automaticly,
- also `empty_value` is not set if field have option `multiple` or `expanded`,
- `empty_value` for `DateType` and `TimeType` can be set "global" or per field, i.e.:

```
$builder->add('date', 'choice', array('required' => false, 'empty_value' => array('day' => 'Choose day')));
```

- `DateType` and `TimeType` code was cleaned a bit,
- added missing option to set up choice list as required when using PHP templates

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

by stloyd at 2011/06/20 04:55:45 -0700

@fabpot I'm just not sure is that change with removing "auto-adding" of `empty_value` is good (probably BC)

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

by lenar at 2011/06/20 05:24:02 -0700

Now this is a really nice way to hijack work done by others. Really encourages newcomers. Gratz!

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

by fabpot at 2011/06/20 05:57:40 -0700

@lenar: if the code in this PR is yours (at least partly), I'm not going to merge it. @stloyd, can you clarify this issue with @lenar? Thanks.

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

by lenar at 2011/06/20 06:21:11 -0700

It's @helmer's mostly, not mine, but the issue stays.

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

by fabpot at 2011/06/20 06:26:15 -0700

No matter who the code belongs to, Git allows us to keep track of all contributors. So, we need to do our best to not loose any code ownership.

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

by helmer at 2011/06/20 06:58:03 -0700

I do not care much for ownership, just that this kind of cooperation (or lack thereof) is kind of exhausting. Closed #1336.

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

by stloyd at 2011/06/20 07:47:53 -0700

@fabpot, @lenar: This PR is inspired by #1336, made by @helmer, but after looking at his code and talking with him, we cant (IMO) get an consensus. So I wrote this PR as an another way to fix issue described in #1336.

__Summary__: I don't think this one is better than fix at #1336, it's more like another approach to fix that issue.

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

by helmer at 2011/06/20 08:15:59 -0700

@stloyd: I actually think your variant is better, so good job there, thanks.

It just ain't nice to:
1) Comment on my changes being useless due to lack of tests
2) Writing brand new testsuite from your perspective that "proves" my approach is "wrong" (while ignoring my answers, why I did something precisely like I did, which I did in sync with @fabpot comments on his first attempt to improve the issue)
3) Saying my PR is broken because your new tests against it fail
4) Changing functionality to "fix" something that was not really broken

Other than that, I wanted to contribute a few lines to improve something relatively simple, and it ended up in a huge mess with more lost hours than I planned to spend on it.

On the bright side, we ended up with something good (:

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

by stloyd at 2011/06/20 08:32:30 -0700

@helmer: 1) & 2) Sorry for that "bad language", but you get me wrong a bit. Tests was written for code in master (there was no problem to change them to work with your POV). 3) Same as before, you can adopt tests easily, but never mind. Maybe later we could cooperate better ;-)
About 4) I mentioned it in description of this PR and that was point I was disagreeing with you (also about how "default" options are adopted in fields) :-)
2011-06-22 22:22:54 +02:00
Alexander
d49e306b9b [DomCrawler] Fixed handling of relative query strings as links 2011-06-22 22:08:01 +02:00
Fabien Potencier
74d539db25 merged branch vicb/form/php-theme (PR #1397)
Commits
-------

5d46e63 [Form] Add the FormHelper configuration
a43fad4 [Form] Improve unit tests for rendering
1cb2129 [FrameworkBundle][Form] Adding a cache to FormHelper::lookupTemplate()
f39ce67 [Form][FrameworkBundle] PHP theming

Discussion
----------

[2.1] RFC [Form] Php theming

This PR implements theming support for the php engine.

It works similarly as the twig theming with themes being folders and blocks being individual files.

There are probably a few things to tune before this can get merged:

### Theme naming

The current format is "\<Bundle\>:\<Controller\>" i.e. "FrameworkBundle:Form".

Is this ok or could you imagine something better ?

### Div and Table theme folders

Currently "FrameworkBundle\\Resources\\views\\Form" and "FrameworkBundle\\Resources\\views\\FormTable"

Is this ok or anything better ?

### Form helper configuration

I am not sure if the configuration is at the best possible location:

```
framework:
    templating:
        form:
            resources: [themeA, themeB]
```

Any better idea ?

There is a [thread on the ml](http://groups.google.com/group/symfony-devs/browse_thread/thread/9b3f131fe116b511)
2011-06-22 22:03:25 +02:00
Alexander
a4451b48cb [DomCrawler] Added tests for links starting with ?foo 2011-06-22 21:49:21 +02:00
Fabien Potencier
da04075c9d merged branch craue/patch-5 (PR #1384)
Commits
-------

c17a836 typo

Discussion
----------

typo
2011-06-22 16:19:27 +02:00
Fabien Potencier
16aa62db0e merged branch lenar/non-blocking-process (PR #1403)
Commits
-------

bda4129 Make run() fully non-blocking and fix potential other problems

Discussion
----------

Make run() fully non-blocking and fix potential other problems

Multiple changes:

1) make writing to process non-blocking too - otherwise there might be increased possibility for buffer deadlock
given big enough input data. Also now it's guaranteed that all stdin data will be written.

2) get rid of fgets() - fgets() isn't really good function to use in case of non-blocking sockets. Data loss possible.
2011-06-22 15:41:58 +02:00
Fabien Potencier
84e87c65cc [HttpFoundation] fixed a bug in previous merge 2011-06-22 15:23:37 +02:00
Fabien Potencier
37521b6fd7 [HttpFoundation] forced Response content to be string 2011-06-22 15:22:06 +02:00
Fabien Potencier
b2b0c4a98f merged branch Seldaek/response (PR #1387)
Commits
-------

7af003b [HttpFoundation] Allow stringable objects and numbers in response body + added tests
8126fb7 [HttpFoundation] Ensure response body is string, fixes #1378

Discussion
----------

[HttpFoundation] Ensure response body is string, fixes #1378

The issue in #1378 is clearly just a misuse of the class due but the error it triggers is confusing. This hopes to fix that.

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

by Seldaek at 2011/06/21 04:08:40 -0700

Added tests and support for __toString + numbers (kinda pointless but well..)
2011-06-22 15:20:49 +02:00
lenar
bda412932b Make run() fully non-blocking and fix potential other problems 2011-06-22 16:16:44 +03:00
Fabien Potencier
1436d8dab7 [Security] added an HttpUtils class to manage logic related to Requests and Responses
This change removes the need for the {_locale} hack.
Now, all paths in the Security component can be:

* An absolute path (/login)
* An absolute URL (http://symfony.com/login)
* A route name (login)

So, if you want to use a path that includes a global parameter (like _locale),
use a route instead of a path.
2011-06-22 14:47:19 +02:00
Fabien Potencier
b91bd78ddb [DoctrineBundle] removed generate:doctrine:entity 2011-06-22 11:45:17 +02:00
Fabien Potencier
7117f41b38 [FrameworkBundle] removed init:bundle (replaced by the generator bundle in Symfony SE) 2011-06-22 11:45:17 +02:00
Victor Berchet
5d46e63089 [Form] Add the FormHelper configuration 2011-06-22 10:27:21 +02:00
Victor Berchet
a43fad409b [Form] Improve unit tests for rendering 2011-06-22 10:27:21 +02:00
Victor Berchet
1cb2129772 [FrameworkBundle][Form] Adding a cache to FormHelper::lookupTemplate() 2011-06-22 10:27:20 +02:00
Victor Berchet
f39ce6709d [Form][FrameworkBundle] PHP theming 2011-06-22 09:23:22 +02:00
Fabien Potencier
e717c99f3b merged branch vicb/form/theming (PR #1369)
Commits
-------

2c1108c [Form] Revert the ability to override anything else than the text of the label while rendering a row
da467a6 [Form] Fix the exception message when no block is found while rendering
8670995 [Form] Optimize rendering when the block to render is known
41e07c9 [Form] Optimize rendering
ee5d975 [Form] Remove a test which is no more relevant (after recent FileType refactoring)
f729c6b [Form] Add the ability to override label & widget options when rendering a row
e09ae3f [Form][FrameworkBundle] Make FormHelper::renderSection() recursively callable, introduce FormHelper::renderBlock()
e43fb98 [Form][TwigBridge] Make FormExtension::render() recursively callable to ease theming

Discussion
----------

[Form] Some refactoring of the rendering

# First two commits

## FormExtension::render() can now be called recursively.

The main use case is theming support in for collections. Let's consider that you have a collection of `CustomType`, the type hierarchy while rendering the proto would be `field < form < custom < prototype`. Before this change any theme applied to your custom type (i.e. a `custom_row` block) would not have been taken into account while rendering the prototype because of the structure of the `prototype_row` block:

```html
{% block prototype_row %}
{% spaceless %}
    <script type="text/html" id="{{ proto_id }}">{{ block('field_row') }}</script>
{% endspaceless %}
{% endblock prototype_row %}
```
which skip the `custom_row` block rendering to fallback to the `field_row` block rendering.

With this PR `prototype_row` recursively calls `FormExtension::render()`

```html
{% block prototype_row %}
{% spaceless %}
    <script type="text/html" id="{{ proto_id }}">{{ form_row(form) }}</script>
{% endspaceless %}
{% endblock prototype_row %}
```

this has for effect to render the block for the parent type (i.e. `custom_row`)

## FormHelper

The `FormHelper` has been updated to more closely match the `FormExtension` architecture and the templates have been modified accordingly. `echo $view['form']->renderBlock(<block name>)` is the php equivalent of `{{ block(<block name>) }}`.

The attributes are now rendered using a template rather than by the `FormHelper::attributes()` method.

Several templates have been fixed.

# Third commit

The `$varStack` property was used to forward options to the label and the widget when rendering a row. The implementation was not working as expected. The proposed way to override label and widget options is to pass these options in the `label` and `widget` keys while callinf `render_row`.

That would be:
`{{ form_row(form.field, {"attr": {<row attributes>}, "label" : {"label": <text>, "attr": {<label attr>}}, "widget" : { "attr" : {<widget attributes}} } }}`

So there is now the ability to set attributes for the row (`<div>` or `<tr>`).

This has been discussed on [the mailing list](http://groups.google.com/group/symfony-devs/browse_thread/thread/17754128ba480545). **I would like to find a compromise with @Seldaek before this gets merged**

The `$varStack` property is now only used when recursively calling `FormExtension::render()`

# Notes

I have preferred to submit several commits in order to ease review and to keep some history.

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

by stof at 2011/06/20 05:20:56 -0700

@vicb On a side note, do you think it would be possible to support form theming in PHP templates too ? Currently, the only way to customize the rendering of forms when using PHP templates is to overwrite the FrameworkBundle's templates, and this impacts all forms. This makes the PHP rendering far less powerful than the Twig one.
I don't know the Form rendering and the PHPEngine well enough to know if it is feasible for 2.1 or not.

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

by vicb at 2011/06/20 05:35:11 -0700

@stof I hope to make it possible but I need a little bit more thinking to find the best possible solution which should not look like a hack.

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

by vicb at 2011/06/21 01:13:10 -0700

This should not be merged yet, it might have some issue with the variable stack. I am working on it.

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

by vicb at 2011/06/21 01:41:11 -0700

Sorted out the issue, it was linked to some local _optimization_, the code of this PR is ok.

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

by vicb at 2011/06/21 02:01:24 -0700

I have pushed a [POC of php theming based on this PR](https://github.com/vicb/symfony/commits/form%2Fphp-theme) to my repo - it is lacking a configuration and cache layer.

I have open [a thread on the ml](http://groups.google.com/group/symfony-devs/browse_thread/thread/9b3f131fe116b511) to discuss this.

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

by vicb at 2011/06/21 23:40:21 -0700

@fabpot fixed in the last commit.
2011-06-22 09:12:24 +02:00
Fabien Potencier
64549525e2 merged branch vicb/form/twig-config (PR #1396)
Commits
-------

39d9a8a [TwigBundle] Fix configuration

Discussion
----------

[TwigBundle] Fix configuration
2011-06-22 09:10:30 +02:00
Victor Berchet
39d9a8ad6e [TwigBundle] Fix configuration 2011-06-22 08:55:52 +02:00
Victor Berchet
2c1108ce6b [Form] Revert the ability to override anything else than the text of the label while rendering a row 2011-06-22 08:36:45 +02:00
Fabien Potencier
f443b9db81 merged branch stof/autoload_doctrine_proxies (PR #1394)
Commits
-------

2d13129 Added an autoloader for doctrine proxies

Discussion
----------

Added an autoloader for doctrine proxies

This registers an autoloader for Doctrine proxies to avoid issues when unserializing proxies. See symfony/symfony-standard#91 for the original discussion.

Not using the CLassLoader component is intended as nothing enforces the proxy directory to follow the PSR-0 convention for the proxy namespace (the default value does but it is not mandatory)
2011-06-22 07:11:03 +02:00
Christophe Coevoet
2d13129e41 Added an autoloader for doctrine proxies 2011-06-21 23:30:22 +02:00
Fabien Potencier
03f9973be8 merged branch frost-nzcr4/typos (PR #1392)
Commits
-------

1cb5164 Replace some double quotes to single quotes
12259d1 Replace optionNal to optional

Discussion
----------

Fixed typo and double quotes within some strings

Fixed typo and double quotes within some strings
2011-06-21 21:33:47 +02:00
Fabien Potencier
1c36d5a529 [Validator] tweaked previous merge 2011-06-21 21:30:03 +02:00
Fabien Potencier
462070058a merged branch blogsh/constraints (PR #1393)
Commits
-------

2f78a44 Changed recognition of constraints in annoations

Discussion
----------

[Validator] Changed recognition of constraints in annotations

I accidently added a constraint to a setter method of an entity:

    /**
     * @Assert\MinLength(2)
     */
    public function setName($name)
    { ... }

The result was that the framework generated the following exception:

     Neither method getTName nor isTName exists in class Blogsh\TestBundle\Entity\User

The problem is that ClassMetadata::addGetterConstraint is called even if the inspected method isn't a getter or an isser.The fix changes the behaviour so that an exception is thrown, saying that it is not valid to add a constraint there. I'm not sure whether this is the right way to handle that problem. It would also be possible to remove the exception and just ignore constraints added to inapplicable methods.
However, the fix prevents the strange error messages from the user.
2011-06-21 21:26:42 +02:00
Sebastian Hörl
2f78a44175 Changed recognition of constraints in annoations 2011-06-21 19:30:26 +02:00
frost-nzcr4
1cb51644e6 Replace some double quotes to single quotes 2011-06-21 21:19:24 +04:00
frost-nzcr4
12259d12cf Replace optionNal to optional 2011-06-21 21:18:10 +04:00
Fabien Potencier
318ae129ad merged branch Seldaek/url_validator (PR #1370)
Commits
-------

159fc0e [Validator] Added symbols to IDNs validation
c827faf [Validator] Add support for IDNs and custom TLDs

Discussion
----------

[Validator] Add support for IDNs and custom TLDs

Minor changes to allow for IDNs and [custom TLDs](http://news.softpedia.com/news/ICANN-Approves-New-Custom-Generic-Top-Level-Domains-Like-google-bank-206977.shtml). This is the only sane way to support everything in a timeless manner.

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

by stealth35 at 2011/06/20 04:32:09 -0700

maybe it should be check the host with idn_to_ascii (if function exists, maybe it's should recreate un punycode en/decoder in the stub)

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

by mvrhov at 2011/06/20 04:40:10 -0700

/me :faceslap.
Haven't seen the link in PR

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

by Seldaek at 2011/06/20 04:40:40 -0700

@mvrhov: Yup, that's what pushed me to reconsider adding this.

@stealth35: I'm not sure if this is needed. I don't want this to be too strict, with another validator or with an extra option I think we can make a check that the domain actually exists, or do a GET / on it or something, but this just checks validity of the syntax.

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

by stealth35 at 2011/06/20 04:48:05 -0700

I understand :)
what about funny IDN like : [☎.com] (http://xn--y3h.com/) ?

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

by Seldaek at 2011/06/20 04:53:19 -0700

@stealth35: Fixed

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

by stealth35 at 2011/06/20 04:56:18 -0700

it's seem great,for acceptable chars [RFC] (http://www.faqs.org/rfcs/rfc3490.html) said (with UseSTD3ASCIIRules option) :

	(a) Verify the absence of non-LDH ASCII code points; that is, the
         absence of 0..2C, 2E..2F, 3A..40, 5B..60, and 7B..7F.
2011-06-21 18:10:17 +02:00
Fabien Potencier
ee95ff2fc5 merged branch Seldaek/event_listener (PR #1374)
Commits
-------

58b6403 Adjusted UPDATE
7350109 Renamed core.* events to kernel.* and CoreEvents to KernelEvents
edbdf7b Rename kernel.listener to kernel.event_listener

Discussion
----------

Rename kernel.listener to kernel.event_listener

Better consistency with doctrine.event_listener

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

by schmittjoh at 2011/06/20 07:39:18 -0700

I think "symfony.event_listener" would be even better then, or just short "event_listener".

There are some more inconsistencies:
- "core.response" -> "kernel.response" / "http_kernel.response"
- "core.request" -> "kernel.request"  / "http_kernel.request"
- "core.controller" -> "kernel.controller"  / "http_kernel.controller"
- "core.view" -> "kernel.view"  / "http_kernel.view"

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

by Seldaek at 2011/06/20 07:45:53 -0700

I proposed `event_listener` but @fabpot didn't like it, `symfony.event_listener` could do, but usual we refer to global stuff as framework more than symfony, so `framework.event_listener`?

The point is that the kernel "owns" the event dispatcher, even if anyone can dispatch his stuff through it. You still listen on the kernel dispatcher. So it's not that wrong imo.

As for the others. I agree that the "core" name is a bit strange. kernel would be more suitable imo. @fabpot?

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

by stof at 2011/06/20 07:50:35 -0700

@Seldaek the issue with having ``kernel`` in the tag name is that some user think that they need to define their own tag when they want to dispatch their own events (I faced it a few times on #symfony and it was also the case in #1298)

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

by Seldaek at 2011/06/20 07:51:55 -0700

Well yeah that's why I liked the idea of having only `event_listener`. IMO even with `framework.event_listener` the confusion can still happen.

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

by fabpot at 2011/06/20 08:00:23 -0700

Renaming `core.response` to `kernel.response` is fine with me.

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

by Seldaek at 2011/06/21 07:53:13 -0700

Ok, added another commit that does that renaming. Updated the two related PRs in -docs and -standard as well.
2011-06-21 18:03:33 +02:00
Jordi Boggiano
58b640376b Adjusted UPDATE 2011-06-21 17:18:34 +02:00
Jordi Boggiano
7350109f6e Renamed core.* events to kernel.* and CoreEvents to KernelEvents 2011-06-21 16:35:14 +02:00
Jordi Boggiano
edbdf7b154 Rename kernel.listener to kernel.event_listener
Better consistency with doctrine.event_listener
2011-06-21 16:35:12 +02:00
Fabien Potencier
73b22e5ad0 merged branch Seldaek/wdt (PR #1390)
Commits
-------

e272d56 [WebProfilerBundle] Fixes toolbar content check

Discussion
----------

[WebProfilerBundle] Fixes toolbar content check

It appears that some html optimizers trim the comments, therefore the old check was not working. This is more robust.

Fixes the issue reported in 8541a5bcbc
2011-06-21 15:06:15 +02:00
Jordi Boggiano
e272d56913 [WebProfilerBundle] Fixes toolbar content check
It appears that some html optimizers trim the comments, therefore the old check was not working. This is more robust.
2011-06-21 13:50:13 +02:00
Jordi Boggiano
7af003b753 [HttpFoundation] Allow stringable objects and numbers in response body + added tests 2011-06-21 13:06:36 +02:00
Fabien Potencier
8541a5bcbc merged branch Seldaek/wdt (PR #1388)
Commits
-------

abd60ac [WebProfilerBundle] Do not display toolbar loading result if it's not a valid toolbar
406c8d8 [WebProfilerBundle] Make toolbar loading non-blocking

Discussion
----------

Non-blocking WDT & prevents garbage to slip in the page

I made the loading non-blocking so that it's not preventing normal operation of the page when the WDT takes a bit long to come up (happens sometimes when the machine is busy).

The second commit also checks that the response looks correct, to prevent stack traces and such to appear in the page if there was a problem. The main issue is not really stack traces though it's mostly with security and intercept_redirect enabled, if you look at a fully secured site you get twice the redirect intercept message to the login page.

Tested in IE7/9/FF4/Opera11
2011-06-21 12:46:53 +02:00
Fabien Potencier
0c5d993c9f merged branch Seldaek/wdt_close (PR #1389)
Commits
-------

f315ad9 [WebProfilerBundle] Make sure the toolbar closes properly

Discussion
----------

[WebProfilerBundle] Make sure the toolbar closes properly

Due to the whitespace element between the div which clears and the toolbar div, in some browsers it was left over after you close the toolbar, this doesn't happen anymore.

Tested in IE7/9/FF4/Opera11
2011-06-21 12:45:24 +02:00
Jordi Boggiano
8126fb7082 [HttpFoundation] Ensure response body is string, fixes #1378 2011-06-21 11:59:20 +02:00
Jordi Boggiano
f315ad950e [WebProfilerBundle] Make sure the toolbar closes properly 2011-06-21 11:58:38 +02:00
Jordi Boggiano
abd60ac345 [WebProfilerBundle] Do not display toolbar loading result if it's not a valid toolbar 2011-06-21 11:57:38 +02:00
Jordi Boggiano
406c8d81ef [WebProfilerBundle] Make toolbar loading non-blocking 2011-06-21 11:56:49 +02:00
Christian Raue
c17a836985 typo 2011-06-20 23:14:48 -07:00
Fabien Potencier
9ceaf6fcbe [SecurityBundle] fixed typo 2011-06-21 08:09:24 +02:00