Commit Graph

8325 Commits

Author SHA1 Message Date
Fabien Potencier
6b9a355fb0 merged branch blogsh/dynamic_constraints (PR #3114)
Commits
-------

92f820a Renamed registerConstraints to loadDynamicValidatorMetadata
dd12ff8 CS fix, getConstraints renamed
09c1911 [Validator] Improved dynamic constraints
54cb6e4 [Validator] Added dynamic constraints

Discussion
----------

[Validator] Dynamic constraints

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes

By now the Validator component is based on a per-class configuration of
constraints, but in some cases it might be neccessary to add new constraints
dynamically at runtime.
This pull request adds a "ConstraintProviderInterface" to the Validator component. If an object is validated that implements this interface the method "getConstraints" is used to add dynamic constraints:

    class User implements ConstraintProviderInterface
    {
        protected $isPremium;
        protected $paymentInformation;

        public function getConstraints(ClassMetadata $metadata)
        {
            if ($this->isPremium) {
                $metadata->addPropertyConstraint('paymentInformation', new NotBlank());
            }
        }
    }

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

by alexandresalome at 2012-01-15T11:20:04Z

Related to #1151

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

by canni at 2012-01-16T09:22:28Z

👍

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

by bschussek at 2012-01-16T12:32:44Z

I think this is a good addition. I think we still have a naming problem though. When constraints are loaded using a static method, the default name for the loader method is `loadValidatorMetadata`. Since the method for dynamic constraint loading is basically the same, I think the two names should be related.

Solution (1): Rename the method in your interface to `loadDynamicValidatorMetadata`. Ugly and long.

    class MyClass implements ConstraintProviderInterface
    {
        public static loadValidatorMetadata(ClassMetadata $metadata) ...

        public loadDynamicValidatorMetadata(ClassMetadata $metadata) ...
    }

Solution (2): Rename the default method name in `StaticMethodLoader` to `registerConstraints` and adjust the docs. Breaks BC.

    class MyClass implements ConstraintProviderInterface
    {
        public static registerConstraints(ClassMetadata $metadata) ...

        public registerDynamicConstraints(ClassMetadata $metadata) ...
    }

@fabpot: Are we allowed to break BC here? If not, we should probably stick to (1).

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

by fabpot at 2012-01-16T12:36:14Z

I would prefer to not break BC if possible.

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

by blogsh at 2012-01-16T15:25:46Z

So "loadDynamicValidatorMetadata" would be the best solution?

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

by althaus at 2012-01-17T13:39:19Z

>So "loadDynamicValidatorMetadata" would be the best solution?

Sounds fine for me based on @bschussek's comment.
2012-01-22 10:26:39 +01:00
Fabien Potencier
811ead8589 [Serializer] fixed unit tests after previous merge + added a new one 2012-01-22 10:20:46 +01:00
Fabien Potencier
54e14e7b11 merged branch sprain/sprain/xml-encoder-cdata (PR #3134)
Commits
-------

9cb513f Now… no more tabs!
7f34643 [Pull Request 3134] Improved code based on comments
90abc0f [Serializer][XmlEncoder] add CDATA padding only if necessary

Discussion
----------

[Serializer][XmlEncoder] add CDATA padding only if necessary

Changed XML encoder so CDATA padding is only added to value if necessary.

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

by fabpot at 2012-01-17T21:34:59Z

You should add some unit tests.
2012-01-22 10:17:12 +01:00
Fabien Potencier
90fcbde685 merged branch canni/fix_cs (PR #3146)
Commits
-------

3cfaade [CS] Fix usage of assertCount

Discussion
----------

[CS] Fix usage of assertCount

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

[![Build Status](https://secure.travis-ci.org/canni/symfony.png)](http://travis-ci.org/canni/symfony)
2012-01-22 10:15:34 +01:00
Gerard van Helden
7c338de412 changed docs as proposed in #3110 2012-01-22 10:13:52 +01:00
Fabien Potencier
3c0b9c5b20 [DoctrineBridge] enhanced an error message (closes #3155) 2012-01-22 10:12:26 +01:00
Fabien Potencier
c7ec49c624 merged branch lstrojny/feature/form-http-delete (PR #3159)
Commits
-------

0b7e2e0 Support for DELETE method in forms

Discussion
----------

[Form] Support DELETE HTTP verb

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

As `Symfony\Component\HttpFoundation\Request` already support DELETE requests nicely by parsing the request for us, support for the HTTPs DELETE verb can be easily done.

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

by mvrhov at 2012-01-20T06:00:49Z

This is wrong. The body for DELETE method is supposed to be empty or if present ignored.
Also the DELETE is supposed to remove the resource identified by uri, so the same code as for GET should be executed.

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

by lstrojny at 2012-01-20T08:56:22Z

I don’t think that’s the case. The HTTP standard does not state explicitly that DELETE does not have a body. See this [StackOverflow thread](http://stackoverflow.com/questions/2539394/rest-http-delete-and-parameters)
2012-01-22 10:05:04 +01:00
Fabien Potencier
09694999b8 merged branch timewasted/patch-1 (PR #3158)
Commits
-------

9e55cda Only call recover() when spool is a Swift_FileSpool
d2a0c74 Use if/else instead of ternary operator
15c666b Add a "recover-timeout" option to allow recovering messages that have taken too long to send

Discussion
----------

[SwiftmailerBundle] Add a "recover-timeout" option to swiftmailer:spool:send

This would allow for easy resending of messages that were marked as being sent, but for whatever reason were never actually sent.
2012-01-22 09:38:58 +01:00
Fabien Potencier
2c962419dc merged branch umpirsky/serbian-translation-update (PR #3167)
Commits
-------

f6b3ea2 New validation messages and translated to Serbian language.

Discussion
----------

New validation messages and translated to Serbian language.

It would be nice for translators to be notified somehow when new validation messages appear. I copied those from French translation, not sure if that is the right way to go?

Also, in addition, I would like to contribute sr@latin translation. To explain, Serbian language have dual alphabet, both cyrillic and latin. I'm not sure if Symfony locale supports locale variants? Can you suggest right translation file name for this?

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

by stof at 2012-01-21T19:20:31Z

Please send the ids up to 41 to the 2.0 branch. Only 42 and above are new in 2.1

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

by stof at 2012-01-21T19:23:48Z

Regarding serbian latin translations, there is an issue here: both cyrillic and latin serbian share the same locale id ``sr_SP``

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

by stof at 2012-01-21T19:33:01Z

ok, looking a bit more about it, it seems like the right way to handle this is to use ``sr_Latn`` and ``sr_Cyrl`` for the 2 variants

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

by umpirsky at 2012-01-21T20:28:37Z

But ids 42 and above can be merged to master (2.1), right?

I think they share `sr_RS`, not `sr_SP` as you said.

So, `validators.sr.xlf` should be renamed to `validators.sr_Cyrl.xlf` and for latig added `validators.sr_Latn.xlf`?

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

by stof at 2012-01-21T21:00:18Z

yeah, but previous ids should be merged in 2.0 first to avoid merge conflicts later

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

by umpirsky at 2012-01-21T22:37:15Z

Done https://github.com/symfony/symfony/pull/3168
2012-01-22 07:34:36 +01:00
Fabien Potencier
a5220313f6 Merge branch '2.0'
* 2.0:
  Updated Serbian translation.
  fixed CS
  [Locale][Testing] Fixed breaking tests if 'intl' extension is not installed (#3139)
  [Bridge] [Twig] fixed typo in a comment of the Twig FormExtension extension.
2012-01-22 07:33:58 +01:00
Fabien Potencier
a0818c753e merged branch umpirsky/2.0 (PR #3169)
Commits
-------

1f733e1 Updated Serbian translation.

Discussion
----------

Updated Serbian translation.

Fixed as requested by stof https://github.com/symfony/symfony/pull/3167#issuecomment-3598347
2012-01-22 07:33:27 +01:00
Sasa Stamenkovic
1f733e1168 Updated Serbian translation. 2012-01-21 23:34:49 +01:00
Fabien Potencier
cbb184c076 merged branch alexandresalome/fix-form-choice-translation-expanded (PR #3166)
Commits
-------

0513eb1 [Form] Pass translation domain to the sub-forms when choice list is expanded

Discussion
----------

[Form] Pass translation domain to the sub-forms when choice list is expanded

* Bug fix: yes
* Tests pass: yes
* Feature addition: no
* BC compatibility break: no

When you have a select list with ``translation_domain``, you loose translations by expanding the list.

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

by stof at 2012-01-21T14:55:31Z

👍

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

by fabpot at 2012-01-21T16:51:17Z

Why not doing that in the 2.0 branch instead?

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

by stof at 2012-01-21T17:26:32Z

@fabpot because the support of translation domains is a 2.1 feature
2012-01-21 21:20:56 +01:00
Sasa Stamenkovic
f6b3ea2d07 New validation messages and translated to Serbian language. 2012-01-21 19:53:48 +01:00
Fabien Potencier
ccdeccbce2 merged branch canni/avoid_rendering_id (PR #3145)
Commits
-------

693d1ec [Form] Do not render default ID attribute on empty form name

Discussion
----------

[Form] Do not render default ID attribute on empty form name

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

[![Build Status](https://secure.travis-ci.org/canni/symfony.png)](http://travis-ci.org/canni/symfony)

This is cleanup after enabling empty form names, now form with empty name
will not render the default `id="form"` container attribute.
Developers can extend/override this behaviour by standard form theming methods.

See discussion [here](https://github.com/symfony/symfony/pull/2936/files)
2012-01-21 17:54:49 +01:00
alexandresalome
0513eb1a4f [Form] Pass translation domain to the sub-forms when choice list is expanded 2012-01-21 14:19:08 +01:00
Ryan
9e55cdaeec Only call recover() when spool is a Swift_FileSpool 2012-01-21 00:49:31 -08:00
Lars Strojny
0b7e2e035a Support for DELETE method in forms 2012-01-20 01:04:31 +01:00
Ryan
d2a0c74e22 Use if/else instead of ternary operator 2012-01-19 13:01:29 -08:00
Ryan
15c666bf43 Add a "recover-timeout" option to allow recovering messages that have taken too long to send 2012-01-19 12:11:55 -08:00
Sebastian Hörl
92f820a094 Renamed registerConstraints to loadDynamicValidatorMetadata 2012-01-18 22:24:42 +01:00
Dariusz Górecki
3cfaade8f7 [CS] Fix usage of assertCount
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
2012-01-18 14:42:47 +01:00
Fabien Potencier
812c72ad8c fixed CS 2012-01-18 13:29:06 +01:00
Dariusz Górecki
693d1ec237 [Form] Do not render default ID attribute on empty form name
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -

This is cleanup after enabling empty form names, now form with empty name
will not render the default `id="form"` container attribute.
Developers can extend/override this behaviour by standard form theming methods.
2012-01-18 10:59:46 +01:00
Fabien Potencier
f842739d58 merged branch jonathaningram/patch-4 (PR #3144)
Commits
-------

076f571 Added missing interface method and updated phpDoc param

Discussion
----------

[Form] add missing interface method

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

Quite simply, the interface misses `get`, but has `add`, `has` and `remove`.

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

by kriswallsmith at 2012-01-18T06:07:10Z

👍
2012-01-18 07:43:37 +01:00
Jonathan Ingram
076f5717a7 Added missing interface method and updated phpDoc param 2012-01-18 17:05:44 +11:00
Fabien Potencier
3d72fae38e merged branch ManuelKiessling/ticket_3139 (PR #3140)
Commits
-------

a1317c3 [Locale][Testing] Fixed breaking tests if 'intl' extension is not installed (#3139)

Discussion
----------

[Locale][Testing] Fixed breaking tests if 'intl' extension is not installed (#3139)

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: ![Build Status](https://secure.travis-ci.org/ManuelKiessling/symfony.png?branch=ticket_3139) Fixes the following tickets: #3139
Todo: -

Symfony\Tests\Component\Locale\LocaleTest->testGetDisplayCountriesReturnsFullListForSubLocale()
fails with a fatal error if the PHP extension 'intl' is not installed on the system.
Added a check which skips the affected tests if the extension is not available.
Fixes #3139
2012-01-17 22:31:20 +01:00
Fabien Potencier
0dd32929e7 merged branch hhamon/form_extension_typo_fix (PR #3138)
Commits
-------

d0da2f9 [Bridge] [Twig] fixed typo in a comment of the Twig FormExtension extension.

Discussion
----------

[Bridge] [Twig] fixed typo in a comment of the Twig FormExtension extension

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
2012-01-17 22:30:37 +01:00
Manuel Kiessling
a1317c3437 [Locale][Testing] Fixed breaking tests if 'intl' extension is not installed (#3139)
Symfony\Tests\Component\Locale\LocaleTest->testGetDisplayCountriesReturnsFullListForSubLocale()
fails with a fatal error if the PHP extension 'intl' is not installed on the system.
Added a check which skips the affected tests if the extension is not available.
Fixes #3139
2012-01-17 18:44:55 +01:00
Hugo Hamon
d0da2f921a [Bridge] [Twig] fixed typo in a comment of the Twig FormExtension extension. 2012-01-17 16:45:13 +01:00
Manuel Reinhard
9cb513f962 Now… no more tabs! 2012-01-17 14:18:32 +01:00
Manuel Reinhard
7f3464386b [Pull Request 3134] Improved code based on comments 2012-01-17 11:25:25 +01:00
Fabien Potencier
e8f9a55012 fixed CS 2012-01-17 11:23:46 +01:00
Fabien Potencier
9c3c53a5c1 merged 2.0 2012-01-17 11:23:18 +01:00
Fabien Potencier
c0c2951554 merged branch Tobion/patch-1 (PR #3130)
Commits
-------

5de5382 improved formatting of changelog-2.1
bf5ccb0 resolved conflict

Discussion
----------

improved markdown formatting of upgrade file

Fixed the indention so that the detailed descriptions are part of the corresponding changelog list item.

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

by fabpot at 2012-01-17T09:24:04Z

It does not merge cleanly.

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

by Tobion at 2012-01-17T10:02:14Z

@fabpot should be good to go now
2012-01-17 11:20:24 +01:00
Tobias Schultze
5de5382666 improved formatting of changelog-2.1 2012-01-17 10:59:45 +01:00
Fabien Potencier
51ecb3c07b fixed CS 2012-01-17 10:56:02 +01:00
Fabien Potencier
706020b38a merged branch henrikbjorn/2.0 (PR #3133)
Commits
-------

959614b Use reflection to determaine the correct path for component validation.xml file

Discussion
----------

2.0

Validation.xml use reflection to guess path
2012-01-17 10:54:23 +01:00
Tobias Schultze
bf5ccb0ae6 resolved conflict 2012-01-17 10:53:31 +01:00
Fabien Potencier
3c3d202255 fixed typo 2012-01-17 10:52:45 +01:00
Manuel Reinhard
90abc0f454 [Serializer][XmlEncoder] add CDATA padding only if necessary
Changed XML encoder so CDATA padding is only added to value if necessary.
2012-01-17 10:51:09 +01:00
Henrik Bjørnskov
959614b4ca Use reflection to determaine the correct path for component validation.xml file 2012-01-17 10:37:10 +01:00
Fabien Potencier
67433813e1 merged branch hhamon/request_collector (PR #3131)
Commits
-------

0c18324 [HttpKernel] added extra information when collecting data from an object if that object implements a __toString().

Discussion
----------

[HttpKernel] added extra information when collecting data from an object...

... if that object implements a __toString().
2012-01-17 10:23:03 +01:00
Hugo Hamon
0c1832450d [HttpKernel] added extra information when collecting data from an object if that object implements a __toString(). 2012-01-17 09:22:00 +01:00
Fabien Potencier
937583dda0 merged branch bschussek/issue3128 (PR #3129)
Commits
-------

43293f4 Updated UPGRADED file to reflect changes merged in e056480ab2

Discussion
----------

[Form] Updated UPGRADED file
2012-01-17 06:45:40 +01:00
Bernhard Schussek
43293f4bc5 Updated UPGRADED file to reflect changes merged in e056480ab2 2012-01-17 00:52:13 +01:00
Fabien Potencier
733ac9de7a [HttpFoundation] fixed exception message (closes #3123) 2012-01-16 22:09:07 +01:00
Fabien Potencier
33170ae572 merged branch ManuelKiessling/ticket_3090_bugfix (PR #3127)
Commits
-------

7e14a56 [Locale] Removed unneccesary semi-colon
cacc880 [Bugfix][Locale] Fixed incomplete Locale data loading

Discussion
----------

[Bugfix][Locale] Fixed incomplete Locale data loading

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: ![Build Status](https://secure.travis-ci.org/ManuelKiessling/symfony.png) Fixes the following tickets: #3090
Todo: -

Sublocales like de_CH returned only incomplete results for
getDisplayCountries(), getDisplayLanguages() and getDisplayLocales(),
consisting only of results specific for this sublocale, but without the
results of their respective parent locale

This PR was https://github.com/symfony/symfony/pull/3106 before - reopened it as a new PR because the commits were too chaotic.
2012-01-16 21:58:33 +01:00
Fabien Potencier
e056480ab2 merged branch bschussek/collection-validator (PR #3118)
Commits
-------

e6e3da5 [Validator] Improved test coverage of CollectionValidator and reduced test code duplication
509c7bf [Validator] Moved Optional and Required constraints to dedicated sub namespace.
bf59018 [Validator] Removed @api-tag from Optional and Required constraint, since these two are new.
6641f3e [Validator] Added constraints Optional and Required for the CollectionValidator

Discussion
----------

[Validator] Improve support for optional/required fields in Collection constraint

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

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=collection-validator)

Improves the `Collection` constraint to test on a more granular level if entries of the collection are optional or required. Before this could only be set using the "allowExtraFields" and "allowMissingFields" options, but these are very general and limited.

The former syntax - without Optional or Required - is still supported.

Usage:

    $array = array(
        'name' => 'Bernhard',
        'birthdate' => '1970-01-01',
    );
    $validator->validate($array, null, new Collection(array(
        'name' => new Required(),
        'birthdate' => new Optional(),
    ));

    // you can also pass additional constraints for the fields
    $validator->validate($array, null, new Collection(array(
        'name' => new Required(array(
            new Type('string'),
            new MinLength(3),
        )),
        'birthdate' => new Optional(new Date()),
    ));

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

by canni at 2012-01-15T20:22:17Z

@bschussek I've rewritten a lot of test code for Collection validator in 2.0 branch and also had modified validator itself, as it had a bug #3078, consider waiting with this PR till fabpot will merge 2.0 back into master, as there will be code conflicts :)

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

by Koc at 2012-01-15T23:13:04Z

Does it helps to #2615 ?

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

by fabpot at 2012-01-16T06:44:53Z

@canni: I've just merged 2.0 into master.

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

by bschussek at 2012-01-16T12:05:19Z

@fabpot: Rebased. I also fixed the CS issues mentioned by @stof.
2012-01-16 21:56:42 +01:00
Fabien Potencier
172300e0de updated CHANGELOG for 2.1 2012-01-16 21:55:17 +01:00