Commits
-------
dbaddbb [Form] Allow empty choices array for ChoiceType
Discussion
----------
[Form] Allow empty choices array for ChoiceType
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
The documentation about ChoiceType says, that default for 'choices' is array().
This is not allowed because an empty array evaluates to false:
if (!$options['choice_list'] && !$options['choices']) {
Use case: choices are empty and items are added dynamically.
---------------------------------------------------------------------------
by chmielot at 2012-02-07T21:03:03Z
Sorry, I messed up with the tickets. Didn't know a pull request opens a ticket.
---------------------------------------------------------------------------
by bschussek at 2012-02-08T08:23:29Z
This ticket depends on #3290 for being merged.
Apart from this, a test case is missing. Add this to ChoiceTypeTest:
// https://github.com/symfony/symfony/issues/3298
public function testInitializeWithEmptyChoices()
{
$this->factory->createNamed('choice', 'name', null, array(
'choices' => array(),
));
}
---------------------------------------------------------------------------
by craue at 2012-02-10T20:32:44Z
@bschussek: Why does it depend on #3290? I have issues with the `!$options['choices']` check even without #3290 applied.
---------------------------------------------------------------------------
by chmielot at 2012-02-10T21:24:28Z
Ok, I updated the branch with the test case and craue's suggestion on explicitly checking valid values.
---------------------------------------------------------------------------
by chmielot at 2012-02-11T09:07:05Z
Should be fine now.
---------------------------------------------------------------------------
by bschussek at 2012-02-11T09:15:10Z
Good. I see that you added a check for \Traversable too - can you add a test for this too? It should be fine to pass an empty \ArrayObject().
---------------------------------------------------------------------------
by craue at 2012-02-11T10:05:36Z
@bschussek: But even if there's passed something different than an array, the c'tor of `SimpleChoiceList` (which is called in line 45) is type hinted with `array` and won't allow passing a `Traversable` anyway, right?
---------------------------------------------------------------------------
by bschussek at 2012-02-11T10:16:36Z
@craue Yes. But in EntityType the choices option is reused and passed to EntityChoiceList, which extends ChoiceList and accepts any array or Traversable.
You're right though that it's not possible to add a test covering this in ChoiceTypeTest, and in EntityTypeTest this is already covered.
@fabpot Ready to merge.
Commits
-------
ac59db7 cleanup
64ea95d [WebProfilerBundle] Add redirection info to the router panel
826bd23 [FrameworkBundle] fix phpDoc of ControllerResolver::createController()
e3cf37f [HttpFoundation] RedirectResponse: add the ability to retrieve the target URL, add unit tests
50c85ae [WebProfiler] Add info to the router panel
Discussion
----------
[WIP][Profiler] Routing
former #3206 part 3 (depends on part 1 - #3280)
The goal of this PR is to fix#3264 by adding redirection infos on the router panel.
Done:
* Add info on the target url / route
To do:
* Display an accurate URL matching process (when using the RedirectableUrlMatcher)
Commits
-------
0d4d7e0 [WebProfilerBundle] Make the toolbar use the common JS
a440279 [WebProfilerBundle] Adds panel pages
762d90d [Profiler] Buid a common infrastructure
Discussion
----------
[Profiler] Provide a common infrastructure
former #3206 part 3
* base JS (provides ajax, toggle, css class helpers),
* panel pages (used only by the Doctrine panel for now).
Successfuly tested with the (future version of the) Doctrine panel.
Commits
-------
22c8f80 [Form] Fixed issues mentioned in the PR comments
3b1b570 [Form] Fixed: The "date", "time" and "datetime" types can be initialized with \DateTime objects
88ef52d [Form] Improved FormType::getDefaultOptions() to see default options defined in parent types
b9facfc [Form] Removed undefined variables in exception constructor
Discussion
----------
[Form] Fixed: "date", "time" and "datetime" fields can be initialized with \DateTime objects
Bug fix: yes
Feature addition: yes
Backwards compatibility break: **yes**
Symfony2 tests pass: yes
Fixes the following tickets: #3288
Todo: -
![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3288)
Fixed exception that was thrown when doing:
$builder->add('createdAt', 'date', array('data' => new \DateTime()));
On a side note, the options passed to `FieldType::getDefaultOptions` now always also contain the default options of any parent types. This is necessary if you want to be independent of how `getDefaultOptions` is implemented in the parent type and still rely on the already defined values.
As a result, `FieldType::getParent` doesn't see default options anymore. This shouldn't be a big problem, because this method only relies on options in few cases. If it does, options now need to be checked for existence with `isset` before being used (BC break).
---------------------------------------------------------------------------
by bschussek at 2012-02-09T16:14:46Z
@fabpot Ready to merge.
---------------------------------------------------------------------------
by bschussek at 2012-02-10T12:15:04Z
@fabpot Ready to merge
Commits
-------
da2447e [Form] Fixed MergeCollectionListener when used with a custom property path
b56502f0 [Form] Added getParent() to PropertyPath
7e5104e [Form] Fixed MergeCollectionListener for the case that the form's data is updated by the data mapper (as happening in CollectionType)
Discussion
----------
[Form] Fixed MergeCollectionListener for the case that the form's data is updated by the data mapper
Bug fix: yes
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3293, #1499
Todo: -
![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3293)
This fixes CollectionType to properly use adders and removers. Apart from that, adders and removers now work with custom property paths. PropertyPath was extended for a method `getParent`.
---------------------------------------------------------------------------
by bschussek at 2012-02-10T07:42:13Z
@fabpot Ready to merge.
Commits
-------
0a4519d [Form] Fixed duplicate errors on forms with "error_bubbling"=false
Discussion
----------
[Form] Fixed duplicate errors on forms with "error_bubbling"=false
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2308
Todo: -
![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue2308)
Commits
-------
6a45a41 [Form] Fixed Form::bindRequest() when used on a form without children
Discussion
----------
[Form] Fixed Form::bindRequest() when used on a form without children
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2553
Todo: -
![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue2553)
Commits
-------
411a0cc [Validator] Added GroupSequenceProvider to changelog
815c769 [Validator] Renamed getValidationGroups to getGroupSequence
d84a2e4 [Validator] Updated test expectations
9f2310b [Validator] Fixed typos, renamed hasGroupSequenceProvider
e0d2828 [Validator] GroupSequenceProvider tests improved, configuration changed
c3b04a3 [Validator] Changed GroupSequenceProvider implementation
6c4455f [Validator] Added GroupSequenceProvider
Discussion
----------
[Validator] Added GroupSequenceProvider
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: ![](https://secure.travis-ci.org/blogsh/symfony.png?branch=dynamic_group_sequence)
As discussed in #3114 I implemented the "GroupSequenceProvider" pattern for the validator component. It allows the user to select certain validation groups based on the current state of an object. Here is an example:
/**
* @Assert\GroupSequenceProvider("UserGroupSequnceProvider")
*/
class User
{
/**
* @Assert\NotBlank(groups={"Premium"})
*/
public function getAddress();
public function hasPremiumSubscription();
}
class UserGroupSequenceProvider implements GroupSequenceProviderInterface
{
public function getValidationGroups($user)
{
if ($user->hasPremiumSubscription()) {
return array('User', 'Premium');
} else {
return array('User');
}
}
}
With this patch there are two mechanisms to define the group sequence now. Either you can use @GroupSequence to define a static order of validation groups or you can use @GroupSequenceProvider to create dynamic validation group arrays.
The ClassMetadata therefore has methods now which implement quite similar things. The question is whether it would make sense to interpret the static group sequence as a special case and create something like a DefaultGroupSequenceProvider or StaticGroupSequenceProvider which is assigned by default. This would cause a BC break inside the validator component.
---------------------------------------------------------------------------
by bschussek at 2012-01-28T13:39:54Z
I like the implementation, but I think we should differ a little bit from Java here.
1. `GroupSequenceProviderInterface` should be implemented by the domain classes themselves (`User`), not by a separate class.
2. As such, the parameter `$object` from `getValidationGroups($object)` can be removed
3. `ClassMetadata::setGroupSequenceProvider()` should accept a boolean to activate/deactivate this functionality. Also the check for the interface (does the underlying class implement it?) should be done here
Apart from that, special cases need to be treated:
* A definition of a group sequence and a group sequence provider in the same `ClassMetadata` should not be allowed. Either of them must not be set.
* Metadata loaders must take care of settings made by parent classes. If `Animal` is extended by `Dog`, `Animal` defines a group sequence (or group sequence provider) and `Dog` a group sequence provider (or group sequence), only the setting of `Dog` should apply
---------------------------------------------------------------------------
by blogsh at 2012-01-28T21:25:37Z
Changes of the latest commit:
- GroupSequenceProviderInterface has to be implemented by the domain class
- The annotation/configuration options let the user define whether the provider is activated or not (is this neccessary at all?)
- An error is thrown if the user wants to use static group sequences and the provider simultaneously
At the moment neither the static group sequence nor the provider is inherited from parent classes or interfaces. I don't know if it would make sense to enable this feature. There could be problems if a user wants to define a static group sequence in the parent class and a sequence provider in the child class.
---------------------------------------------------------------------------
by bschussek at 2012-01-30T13:07:04Z
> There could be problems if a user wants to define a static group sequence in the parent class and a sequence provider in the child class.
In this case, the setting in the child class should override the setting of the parent class.
But we can leave this open for now. As it seems, [this issue is unresolved in Hibernate as well](https://hibernate.onjira.com/browse/HV-467).
---------------------------------------------------------------------------
by blogsh at 2012-01-30T22:54:41Z
Okay, finally I managed to upload the latest commit. If you got a bunch of notifications or so I'm sorry, but I had to revert some accidental changes in the commit :(
I've rewritten the tests and have removed the "active" setting in the XML configuration.
---------------------------------------------------------------------------
by blogsh at 2012-02-02T15:24:01Z
Okay, typos are fixed now and `hasGroupSequenceProvider` has been renamed to `isGroupSequenceProvider`. I also had to adjust some tests after the rebase with master.
---------------------------------------------------------------------------
by bschussek at 2012-02-03T09:25:19Z
Looks good.
@fabpot 👍
---------------------------------------------------------------------------
by fabpot at 2012-02-03T09:46:52Z
Can you add a note in the CHANGELOG before I merge? Thanks.
---------------------------------------------------------------------------
by blogsh at 2012-02-09T12:31:27Z
@fabpot done
Commits
-------
f143822 Removed invalid dependencies and replaces in composer.json
Discussion
----------
Removed invalid dependencies and replaces in composer.json
Commits
-------
42c9892 [FrameworkBundle] Allow cache:clear/warmup to skip optional warmers
Discussion
----------
[FrameworkBundle] Allow cache:clear/warmup to skip optional warmers
> Bug fix: no
> Feature addition: yes
> Backwards compatibility break: yes
> Symfony2 tests pass: [yes](http://travis-ci.org/#!/jmikola/symfony/builds/647861)
Exercise.com has been using this for a while for our local environments. Skipping the optional cache warmers (namely Assetic) can save quite a bit of time.
Commits
-------
ba3b321 [ClassLoader] Added a class map file generator utility
Discussion
----------
[ClassLoader] Added a class map file generator utility
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2407
---------------------------------------------------------------------------
by lsmith77 at 2011-11-30T19:33:52Z
@thesalla do you have time/interest to finish this up?
---------------------------------------------------------------------------
by thesalla at 2011-12-01T09:55:50Z
sure (will attempt at least), but no sooner than tomorrow
---------------------------------------------------------------------------
by stof at 2011-12-12T20:41:41Z
@thesalla @fabpot what is the state of this PR ?
---------------------------------------------------------------------------
by thesalla at 2011-12-17T19:36:58Z
If you don't have any other suggestions or ideas, I'd consider it finished.
---------------------------------------------------------------------------
by lsmith77 at 2012-01-24T09:27:12Z
ping
---------------------------------------------------------------------------
by fabpot at 2012-02-02T08:21:38Z
@thesalla: Can you rename the ClassMapDumper class to ClassMapGenerator and then squash your commit before the merge? Thanks.
---------------------------------------------------------------------------
by thesalla at 2012-02-04T12:55:48Z
@fabpot done.
Commits
-------
928e352 Change the array access used in UniqueEntityValidator
Discussion
----------
[DoctrineBridge] Change the array access used in UniqueEntityValidator
MongoDB ODM Cursor does not implement ArrayAccess and therefor using
`$result[0]` will fail. `reset()` rewinds the array and returns the
first element value.
DoctrineMongoDBBundle#77
/cc @beberlei
---------------------------------------------------------------------------
by henrikbjorn at 2012-02-06T08:09:25Z
Made a mistake, the findBy call would still return a cursor. Changed the findBy to findOneBy we only want one result anyway.
---------------------------------------------------------------------------
by stof at 2012-02-06T08:11:26Z
findOneBy is wrong: you will not detect duplicate anymore if you return a single element
---------------------------------------------------------------------------
by henrikbjorn at 2012-02-06T08:28:03Z
@stof before it was only the first result that was used anyway so if it had found 3 results it would only have used the first one. Performance is apparently the biggest issue with findOneBy so this have been reverted.
---------------------------------------------------------------------------
by stof at 2012-02-06T08:31:17Z
@henrikbjorn no, we use other results too: if ``count()`` is not 1, the validation fails
---------------------------------------------------------------------------
by stof at 2012-02-06T08:36:06Z
Btw, running the testsuite would have tell you there is an issue when using findOneBy as it was breaking a test :)
---------------------------------------------------------------------------
by bschussek at 2012-02-06T10:45:44Z
Why doesn't this validator use a SELECT COUNT anyway?
---------------------------------------------------------------------------
by stof at 2012-02-06T10:57:00Z
@bschussek because we need to check if an existing value is for the same object or another one. Otherwise, the valdiation would fail as soon as you are editing an existing object without changing the unique value
---------------------------------------------------------------------------
by henrikbjorn at 2012-02-06T11:03:40Z
@stof @bschussek other changes that should be done? Else it should be ready to be merged ?
---------------------------------------------------------------------------
by henrikbjorn at 2012-02-06T13:00:57Z
@stof done an rebased.
---------------------------------------------------------------------------
by bschussek at 2012-02-06T13:04:44Z
👍 /cc @fabpot
Commits
-------
b65a997 [Form] Added test ChoiceList::testGetChoicesForValuesCorrectOrderingOfResult for correct ordering check
a60daff [Form] Fixed incorrect sorting in ChoiceList::getChoicesForValues
Discussion
----------
[Form] Fixed incorrect sorting in ChoiceList::getChoicesForValues
ChoiceList::getChoicesForValues return collection with sorting, that not corresponding to the sorting for input keys
---------------------------------------------------------------------------
by bschussek at 2012-02-03T21:40:49Z
Can you adapt the test cases to fail for this case please? (probably by use of assertSame instead of assertEquals in one of the existing tests)
---------------------------------------------------------------------------
by grizlik at 2012-02-04T08:41:44Z
I need to create a new test or modify an existing one?
---------------------------------------------------------------------------
by bschussek at 2012-02-04T09:58:04Z
Something like this in ChoiceListTest:
public function testGetChoicesForValuesReverseOrderedValues()
{
$values = array('2', '1');
$this->assertSame(array($this->obj3, $this->obj2), $this->list->getChoicesForValues($values));
}