Commit Graph

149 Commits

Author SHA1 Message Date
Disquedur 51312d31cc Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
Laurent Ghirardotti 638ce847b3 [Doc] Use Markdown syntax highlighting 2014-10-01 07:38:33 +02:00
Dariusz Górecki 7c47e34928 [CS Fix] Consistent coding-style of concatenation operator usage 2013-04-02 10:39:57 +01:00
Fabien Potencier 18495e7b3c Merge branch '2.1'
* 2.1: (29 commits)
  [DependencyInjection] fixed composer.json
  [Validator] Fix typos in validators.ru.xlf
  Edited some minor grammar and style errors in russian validation file
  Updated Bulgarian translation
  [Form] improve error message with a "hasser" hint for PropertyAccessDeniedException
  [Form] Updated checks for the ICU version from 4.5+ to 4.7+ due to test failures with ICU 4.6
  [Form] simplified a test from previous merge
  Update src/Symfony/Component/Form/Extension/Core/Type/FileType.php
  fixed CS
  Xliff with other node than source or target are ignored
  small fix of #5984 when the container param is not set
  Filesystem Component mirror symlinked directory fix
  [Process][Tests] fixed chainedCommandsOutput tests
  fixed CS
  Use better default ports in urlRedirectAction
  Add tests for urlRedirectAction
  info about session namespace
  fix upgrade info about locale
  Update src/Symfony/Component/DomCrawler/Tests/FormTest.php
  Update src/Symfony/Component/DomCrawler/Form.php
  ...
2012-11-29 11:32:45 +01:00
Tobias Schultze 915dd301e4 info about session namespace 2012-11-19 17:25:14 +01:00
Tobias Schultze 4b21d18738 fix upgrade info about locale
it duplicated the header and had an irrelevant point inbetween
2012-11-19 17:13:42 +01:00
Moritz Borgmann 04e93d82d3 Update UPGRADE-2.1.md
Change on selectedchoice part, because "choice.value" wont work, but just "value" does.
2012-11-07 13:13:48 +01:00
Grégoire Paris 6fb4a1bbdc Remove § about prototype_name customization in 2.0
I don't think this was even possible in 2.0
2012-10-25 10:33:18 +02:00
Grégoire Paris 8a347fdba6 fix option name 2012-10-25 10:33:03 +02:00
Peter Kruithof 3e15d448af Documented removed _form_is_choice_group function
Also changed for-loop variables to match the current `form_div_layout.html.twig` code.
2012-10-19 11:53:49 +03:00
Florent Cailhol 632e6bfa92 Fix typo 2012-10-16 11:27:35 +02:00
Kevin McBride bb0e4c3090 Fixed FlashBagInterface phpdoc, clarified UPGRADE docs 2012-09-19 13:48:54 -07:00
Thomas Tourlourat 6d49bfb394 Remove "you" word. 2012-09-04 12:35:57 +03:00
Johannes M. Schmitt 0f575a25b0 added note about 404 error pages 2012-08-22 19:38:06 +02:00
Fabien Potencier 1996c1fa1d fixed typos in the UPGRADE file 2012-08-16 20:10:26 +02:00
Fabien Potencier 24e2fcbff0 merged branch TomAdam/pr-choice-bc-doc (PR #5263)
Commits
-------

9e3e589 Alter upgrade notes with changes to _form_is_choice_selected twig function

Discussion
----------

Undocumented BC break - choice field type template

The upgrade notes for the choice field template are out of date. They currently state:

```
The `choices` variable now contains `ChoiceView` objects with two getters,
getValue() and getLabel(), to access the choice data.
```

However these methods do not exist. I assume this is the result of a rollback to maintain BC?

In addition to this, the `_form_is_choice_selected` twig function has been removed and replaced with a filter called `selectedchoice`. This is an undocumented BC break. I have attached an update to the notes to reflect these changes.

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

by fabpot at 2012-08-15T17:20:35Z

ping @bschussek

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

by bschussek at 2012-08-16T17:36:22Z

Looks good apart from my comment. Thanks for fixing this!
2012-08-16 20:09:02 +02:00
Fabien Potencier c15a3a33ef fixed typo in the UPGRADE file 2012-08-16 19:56:58 +02:00
Tiago Ribeiro 4b5adcddee Typo in UPGRADE-2.1 2012-08-16 12:56:42 +02:00
Tom Adam 9e3e5897bd Alter upgrade notes with changes to _form_is_choice_selected twig function 2012-08-14 23:02:27 +01:00
Richard Miller 2c3a7bf57b Added before/after examples of change in registering security factories to upgrade info. 2012-08-02 12:39:17 +01:00
Bernhard Schussek 2185ca80e2 [Validator] Added entry point "Validation" for more convenient usage outside of Symfony2 2012-07-30 11:41:40 +02:00
Bernhard Schussek 8070e6997e [Form] Fixed ResolvedFormType to really be replaceable 2012-07-29 19:13:45 +02:00
marc.weistroff d30943c2e8 [FrameworkBundle] Switched to parameters for request context host and scheme 2012-07-26 11:12:14 +02:00
Tobias Schultze 22dfa7de54 remove relict in upgrade 2012-07-23 19:12:06 +03:00
Bernhard Schussek dc3a680cd3 [Form] Improved FormRenderer API to reduce the size of the function call stack during rendering 2012-07-22 09:29:35 +02:00
Bernhard Schussek 310f985b99 [Form] Added a layer of 2.0 BC methods to FormView and updated UPGRADE and CHANGELOG 2012-07-21 13:49:32 +02:00
Michael Piecko f5e03a3716 Changed $request->setDefaultLocale() to $request->setLocale() in custom LocaleListener. 2012-07-19 15:48:21 +03:00
Fabien Potencier cb82287416 merged branch weaverryan/upgrade-listener-priorities (PR #4928)
Commits
-------

96638f4 [UPGRADE] Tweaking formatting error with event listener section. Also tweaking values

Discussion
----------

[UPGRADE] Tweaking formatting error with event listener section and information

Hey guys!

This is just a documentation change based on sha: 5da1bc6a4f

Check out the details in the commit message - I'm not sure if this is right, but the original commit seemed a bit odd compared to what I was seeing in the code. There was also a fix to the formatting.

If I've missed something, I'm happy to change the commit as needed.

Thanks!

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

by stof at 2012-07-14T21:53:12Z

There is no equivalent to early_kernel_request for the router listener as both methods have been merged together (it was separated so that the initialization of the RequestContext was done before the firewall, but the whole logic is before the firewall now)
2012-07-18 17:00:08 +02:00
Fabien Potencier 1570db9646 merged branch bschussek/performance (PR #4918)
Commits
-------

1474aa5 [Form] Fixed consideration of Twig's template inheritance and added another performance-improving check
b4ec7f5 Fixed my rubbish English
d11f8b5 [Form] Fixed passing of variables in the FormRenderer
629093e [Form] Extracted common parts of FormHelper and FormExtension into separate classes
216c539 [Form] Implemented a more intelligent caching strategy in FormHelper (PHP +100ms, Twig +100ms)

Discussion
----------

[Form] Merged FormHelper and FormExtension and implemented a better caching strategy

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

This PR extracts common parts of `FormHelper` and `FormExtension` into implementations of the new interfaces `FormRendererInterface` and `FormRendererEngineInterface`. The implemented `AbstractRendererEngine` features a more intelligent caching strategy than the one used before. When this strategy was implemented directly in `FormHelper`, the performance of [this specific, heavy form](http://advancedform.gpserver.dk/app_dev.php/taxclasses/1) could be improved from **2.5** to **2.25 seconds** on my machine for PHP templates.

Due to the abstraction and delegation, the performance gain is not that big anymore, but we still have a performance gain of about **0.1 seconds** for both PHP and Twig in the above example. The second, big improvement of this PR is maintainability - the differences between PHP and Twig templates are now contained in relatively small classes - and extendability (it is very easy now to support different template engines).

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

by stof at 2012-07-14T13:47:19Z

should a similar refactoring be done for the [Twig rendering](https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/FormExtension.php) ?

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

by bschussek at 2012-07-14T13:49:25Z

Yes. I would like to merge the common parts of Twig's FormExtension and PHP's FormHelper into an abstract class. Before that I need to have a [working, heavy Twig Form](https://twitter.com/webmozart/status/224135287377371138) in order to measure whether I don't actually decrease the performance with Twig. Can you help me there?

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

by vicb at 2012-07-16T21:48:24Z

Would it make sense to create a 'renderer' folder in the form component and move related classes there ?

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

by stof at 2012-07-16T22:06:58Z

@vicb It makes sense to keep the Twig renderer in the brisge. This is what the bridge is about. Moving the Twig class to the component would not be consistent. And the PHP renderer is already in the component (but it could make sense to move the helper from FrameworkBundle to the TemplatingExtension of the Form component though)

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

by vicb at 2012-07-16T22:16:50Z

@stof I was only referring to the classes located in the Component/Form folder.

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

by vicb at 2012-07-16T22:27:27Z

Overall I don't really know what to think of this PR. PHP and Twig use a different way to support blocks:

- PHP has one block per file,
- Twig could have many blocks per templates.

I am not sure if this PR is optimal for Twig and improves maintainability ?

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

by stof at 2012-07-16T22:46:11Z

@vicb it avoids duplicating the whole rendering logic for each engine (there is at least a third one in [SmartyBundle](https://github.com/noiselabs/SmartyBundle/blob/master/Extension/FormExtension.php) btw)

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

by bschussek at 2012-07-17T07:16:42Z

@vicb I don't think a renderer subfolder makes sense. The interfaces belong to the main namespace, and then the subfolder would only contain two classes.

Considering maintainability for Twig, I think that this PR in fact increases it. TwigExtension before always had to check the whole type hierarchy, while now the code in AbstractRendererEngine makes sure that this process is speeded up.

Before:
```
load _some_entity_field_label:
    - check _some_entity_field_label
    - check entity_label
    - check choice_label
    - check form_label

load _some_other_entity_field_label
    - check _some_other_entity_field_label
    - check entity_label
    - check choice_label
    - check form_label

a.s.o.
```

After:
```
load _some_entity_field_label:
    - check _some_entity_field_label
    - check entity_label (hits the cache if entity_label was checked before)
    - check choice_label (hits the cache if choice_label was checked before)
    - check form_label

load _some_other_entity_field_label
    - check _some_other_entity_field_label
    - check entity_label (now definitely hits the cache)

a.s.o.
```

Since many fields share the same ancestors in the inheritance tree, this definitely improves performance.

As can also be deducted here, custom block names such as `_some_entity_field_label` are now a major drawback. There is nothing we can cache for them, so they need to be checked for every individual block that we load. Removing this feature surprisingly gains no performance for Twig (I need to investigate why at some point), but it speeds up rendering for **250ms** using the PHP engine on [this example form](advancedform.gpserver.dk/app_dev.php/taxclasses/1), dropping the rendering time from 1.25 to 1 sec on my local machine. I'm not sure what we should do here.

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

by stof at 2012-07-17T07:21:31Z

@bschussek could it be possible to have an implementation checking the custom block and another one skipping it ? This way, the user could disable this feature when he does not need it.

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

by bschussek at 2012-07-17T07:38:34Z

@stof It would be possible to add a switch to `FormRenderer` that controls whether custom blocks are checked or not.

If this switch is disabled by default, we break BC. If this switch is enabled by default, it will be pretty useless. People will start designing away for custom blocks, and once they want to improve performance, they can't turn off the switch anymore because it would require too many changes.

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

by stof at 2012-07-17T08:08:38Z

@fabpot what do you think about it ?

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

by bschussek at 2012-07-17T08:41:43Z

Another option that just came to mind is to remove inheritance checks for anything but _widget and _row. I.e., if we render `entity_widget`, check
```
_id_widget
entity_widget
choice_widget
form_widget
```
But if we render `entity_label`, only check
```
_id_label
form_label
```

This improves PHP Templating for **170ms** and Twig for **20ms**. We gain another **150ms** for PHP Templating and **~15ms** for Twig if we also restrict custom fields (_id_widget) to the _widget and _row suffixes (it's really hard to tweak the renderer for Twig.. I think a lot of its performance bottlenecks lie in Twig itself).

Do you have any data on how often blocks other than _widget and _row are customized for specific types/IDs?

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

by stof at 2012-07-17T09:47:38Z

Well, I think most of the time other blocks are not even customized based on the type :)

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

by Tobion at 2012-07-17T14:32:39Z

From my experience rendering the form components individually is easier and more flexible than customizing by ID or type.
But there are still use cases for customizing like library-like bundles (e.g. Bootstrap).
2012-07-18 08:33:15 +02:00
Tobias Schultze 5233984ec0 fix class name in upgrade 2012-07-18 07:53:58 +03:00
Bernhard Schussek 629093ed25 [Form] Extracted common parts of FormHelper and FormExtension into separate classes 2012-07-16 21:39:27 +02:00
Ryan Weaver 96638f4332 [UPGRADE] Tweaking formatting error with event listener section. Also tweaking values
Some of the values here are either wrong, or are drawing their logic from an area I can't find. I've used the following logic for this change:

* security.firewall - this is easy, it just changed

* locale listener - this didn't exist in Symfony 2.0, but it was done on the RouterListener::onKernelRequest(), which had a priority of 0. The new listener has a priority of 16

* The early request router listener is gone - I'm not sure it has an equivalent

* The RouterListener priority changed from 0 to 32
2012-07-14 16:45:36 -05:00
Bernhard Schussek 69e5e58629 [Form] Individual rows of CollectionType cannot be styled anymore for performance reasons 2012-07-14 12:10:29 +02:00
Bernhard Schussek cd7835d8d2 [Form] Cached the form type hierarchy in order to improve performance 2012-07-13 20:39:30 +02:00
Bernhard Schussek a92f80b815 [Validator] Added Length constraint and deprecated MinLength and MaxLength 2012-07-11 19:48:02 +02:00
Bernhard Schussek 83a3f75b2d [Validator] Deprecated the constraints Min and Max in favor of Range 2012-07-11 19:48:02 +02:00
Bernhard Schussek 0be602deef [Validator] Deprecated the Size constraint 2012-07-11 15:48:36 +02:00
Fabien Potencier f3547d4ff1 merged branch bschussek/testfix (PR #4847)
Commits
-------

7a76dba [Form] Renamed the options "data_timezone" and "user_timezone"
655d645 [Form] Fixed tests failing on systems with timezones other than +01:00

Discussion
----------

[Form] Fixed tests and renamed the options "data_timezone" and "user_timezone"

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

The option names were renamed for better consistency with the terms "model data" or "model format" and "view data" or "view format".
2012-07-11 09:47:34 +02:00
Bernhard Schussek 7a76dbad20 [Form] Renamed the options "data_timezone" and "user_timezone" 2012-07-11 09:44:09 +02:00
Fabien Potencier 5da1bc6a4f added missing listener priority changes in the UPGRADE file (refs #2680) 2012-07-11 09:36:00 +02:00
Bernhard Schussek 7727de73e5 [Form] Deprecated Form::bindRequest() and replaced it by a PRE_BIND listener 2012-07-09 20:34:45 +02:00
Bernhard Schussek c0a520792b [Form] Prevented duplicate validation of form constraints 2012-07-09 19:28:39 +02:00
Michaël Perrin 81eb7222d2 Simpler sentence concerning upgrade of the form_label function 2012-07-09 18:15:43 +03:00
Michaël Perrin f6f1bb5e02 Update to the "Upgrade to v2.1" documentation: the way HTML attributes are passed for the `form_label` function has changed. 2012-07-09 17:14:03 +02:00
Fabien Potencier d6d1d91766 fixed markup 2012-07-09 14:19:00 +02:00
Bernhard Schussek c09bad8aea [Form] Clarified how to adapt forms that inherited from FieldType for Symfony 2.1 2012-07-06 19:15:07 +02:00
Frédéric Hardy 615558394a Remove bug in locale management in listener. 2012-07-03 16:15:48 +02:00
Fabien Potencier 81fe2ff8e2 merged branch fabpot/locale-listener (PR #4692)
Commits
-------

88caf3a [HttpKernel] removed the storage of the current locale in the session

Discussion
----------

[HttpKernel] removed the storage of the current locale in the session

Before this commit, the current locale was stored in the session (if one
was already started). That way, for the next requests, even if the
request locale attribute was not set, the locale was "restored".

But this is a really bad practice as it means that the same URL can have
a different content depending on the previous requests. It would have
been better if the Vary header was set but the locale can be different
from the value coming from the Accept-Language anyway.

This is a BC break but fortunately, you can restore the 2.0 behavior by
creating a simple event listener that contains the logic removed by this
commit.

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

by travisbot at 2012-07-01T06:56:48Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1748659) (merged 009e30f0 into 2e356c1a).

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

by schmittjoh at 2012-07-01T08:15:46Z

How about using a cookie instead? It would remove the BC break, and also be possible to use a vary header?

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

by fabpot at 2012-07-01T09:13:44Z

The goal is to make Symfony as stateless as possible; introducing a cookie would defeat this goal.

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

by drak at 2012-07-01T09:19:37Z

@fabpot - thank you for bringing this to attention. I was meaning to do it a long time ago. The requested language is entirely a per request issue and must always be so. URLs must only ever return one content, and not multiple (e.g. different languages). The correct way to behave is to detect the language based on URL and failing that where a language is not requested, to look at the preferred language from the browser request and if available it can be redirected to that resource (e.g. /fr). This is what we do in Zikula. We have a further session based setting for "preferred language" which if set will override the browser default.

In summary:

1. If the language is specified in the GET request, return that language always. E.g. domain.com/fr/foo should return a French version of foo

2. If no language is specified in the GET request: first check the session for a preferred language, otherwise check the browser string for the preferred language and then if necessary, redirect to that resource. We have a setting which additionally say "always have language in URL, and don't put language code in URL for default language"

This means what in Zikula we only ever have one URL per language version of a page, but it still allows for users to set their preferred language which is taken in to account mainly when they visit the homepage (but in fact any page without a specific language in the request).

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

by drak at 2012-07-01T09:38:06Z

+1 on this PR. Basically the request locale should be in the Request object and calculated according to the applications preferences.

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

by schmittjoh at 2012-07-01T12:38:25Z

I agree that content must be detected based on the request, but I strongly disagree with relying entirely on the URL.

@fabpot, if you think about it using a cookie would still be stateless. There would be no state whatsoever, the detection would be entirely based on the request. Whether the language information is transmitted in the URL or as part of request headers is for the developer to decide eventually, at least IMO. My suggestion would just provide a default which is more BC.

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

by drak at 2012-07-01T20:08:50Z

@schmittjoh it's not entirely from the URL, there are browser preferences and also user defaults ca nalso available but the latter is slightly higher level. IMO it's not really Symfony's job here, it's application level specific. We have a pretty good working example of that in Zikula. Anyone can easily implement your own requirements with a listener.

What is absolutely clear however is it is wrong for one URL to deliver more than one version of any content.

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

by schmittjoh at 2012-07-01T21:16:52Z

I'm 100% for this change. My suggestion would just be more BC while still keeping Symfony2 stateless. Of course, it can be easily implemented in userland if we do not care about BC here.

Regarding different URLs per content, I do not think that this is our decision to make. Generally, developers should be able to make whatever content negotation they see fit. Whether they rely solely on the URL, or also take other request headers into account should not be limited by Symfony2.

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

by fabpot at 2012-07-02T10:37:26Z

I've added a paragraph in the UPGRADE file with a listener example that can be used to keep BC.
2012-07-02 12:37:57 +02:00
Fabien Potencier 88caf3a370 [HttpKernel] removed the storage of the current locale in the session
Before this commit, the current locale was stored in the session (if one
was already started). That way, for the next requests, even if the
request locale attribute was not set, the locale was "restored".

But this is a really bad practice as it means that the same URL can have
a different content depending on the previous requests. It would have
been better if the Vary header was set but the locale can be different
from the value coming from the Accept-Language anyway.

This is a BC break but fortunately, you can restore the 2.0 behavior by
creating a simple event listener that contains the logic removed by this
commit.
2012-07-02 12:36:25 +02:00
Fabien Potencier c0e4760b38 merged branch kriswallsmith/form/mv-humanize (PR #4645)
Commits
-------

c1e4166 moved create of default form label to view layer

Discussion
----------

move create of default form label to view layer

A small optimization if you provide custom labels in the view layer (i.e. `{{ form_label(form.name, 'Your name') }}`

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

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

by travisbot at 2012-06-24T14:45:17Z

This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1694310) (merged 37f0b774 into 0d4b02e4).

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

by travisbot at 2012-06-24T15:03:44Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1694418) (merged c1e4166e into 0d4b02e4).
2012-07-01 22:38:07 +02:00