minor #14200 [Form] Updated CHANGELOG and UPGRADE files (webmozart)

This PR was merged into the 2.7 branch.

Discussion
----------

[Form] Updated CHANGELOG and UPGRADE files

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR includes the changes from #14050 in the CHANGELOG/UPGRADE files.

Commits
-------

6863ba5 [Form] Updated CHANGELOG and UPGRADE files
This commit is contained in:
Fabien Potencier 2015-04-03 19:03:03 +02:00
commit be0c98efaf
4 changed files with 421 additions and 23 deletions

View File

@ -29,36 +29,405 @@ Form
Before:
```php
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
{
// ...
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
// ...
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Task',
));
}
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Task',
));
}
}
```
After:
```php
use Symfony\Component\OptionsResolver\OptionsResolver;
class TaskType extends AbstractType
use Symfony\Component\OptionsResolver\OptionsResolver;
class TaskType extends AbstractType
{
// ...
public function configureOptions(OptionsResolver $resolver)
{
// ...
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Task',
));
}
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\Task',
));
}
}
```
* The "choice_list" option of ChoiceType was deprecated. You should use
"choices_as_values" or "choice_loader" now.
Before:
```php
$form->add('status', 'choice', array(
'choice_list' => new ObjectChoiceList(array(
Status::getInstance(Status::ENABLED),
Status::getInstance(Status::DISABLED),
Status::getInstance(Status::IGNORED),
)),
));
```
After:
```php
$form->add('status', 'choice', array(
'choices' => array(
Status::getInstance(Status::ENABLED),
Status::getInstance(Status::DISABLED),
Status::getInstance(Status::IGNORED),
),
'choices_as_values' => true,
));
```
* You should flip the keys and values of the "choices" option in ChoiceType
and set the "choices_as_values" option to `true`. The default value of that
option will be switched to `true` in Symfony 3.0.
Before:
```php
$form->add('status', 'choice', array(
'choices' => array(
Status::ENABLED => 'Enabled',
Status::DISABLED => 'Disabled',
Status::IGNORED => 'Ignored',
)),
));
```
After:
```php
$form->add('status', 'choice', array(
'choices' => array(
'Enabled' => Status::ENABLED,
'Disabled' => Status::DISABLED,
'Ignored' => Status::IGNORED,
),
'choices_as_values' => true,
));
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\ChoiceListInterface` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface;
public function doSomething(ChoiceListInterface $choiceList)
{
// ...
}
```
After:
```php
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
public function doSomething(ChoiceListInterface $choiceList)
{
// ...
}
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\View\ChoiceView` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\View\ChoiceView` instead.
Note that the order of the arguments passed to the constructor was inverted.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\View\ChoiceView;
$view = new ChoiceView($data, 'value', 'Label');
```
After:
```php
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
$view = new ChoiceView('Label', 'value', $data);
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
$choiceList = new ChoiceList(
array(Status::ENABLED, Status::DISABLED, Status::IGNORED),
array('Enabled', 'Disabled', 'Ignored'),
// Preferred choices
array(Status::ENABLED),
);
```
After:
```php
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
$factory = new DefaultChoiceListFactory();
$choices = array(Status::ENABLED, Status::DISABLED, Status::IGNORED);
$labels = array('Enabled', 'Disabled', 'Ignored');
$choiceList = $factory->createListFromChoices($choices);
$choiceListView = $factory->createView(
$choiceList,
// Preferred choices
array(Status::ENABLED),
// Labels
function ($choice, $key) use ($labels) {
return $labels[$key];
}
);
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory::createListFromLoader()`
together with an implementation of
`Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList;
class MyLazyChoiceList extends LazyChoiceList
{
public function loadChoiceList()
{
// load $choiceList
return $choiceList;
}
}
$choiceList = new MyLazyChoiceList();
```
After:
```php
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
class MyChoiceLoader implements ChoiceLoaderInterface
{
// ...
}
$factory = new DefaultChoiceListFactory();
$choiceList = $factory->createListFromLoader(new MyChoiceLoader());
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
$choiceList = new ObjectChoiceList(
array(Status::getInstance(Status::ENABLED), Status::getInstance(Status::DISABLED)),
// Label property
'name'
);
```
After:
```php
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
$factory = new DefaultChoiceListFactory();
$choiceList = $factory->createListFromChoices(array(
Status::getInstance(Status::ENABLED),
Status::getInstance(Status::DISABLED),
));
$choiceListView = $factory->createView(
$choiceList,
// Preferred choices
array(),
// Label property
'name'
);
```
* `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
$choiceList = new SimpleChoiceList(array(
Status::ENABLED => 'Enabled',
Status::DISABLED => 'Disabled',
));
```
After:
```php
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
$factory = new DefaultChoiceListFactory();
$choices = array(Status::ENABLED, Status::DISABLED);
$labels = array('Enabled', 'Disabled');
$choiceList = $factory->createListFromChoices($choices);
$choiceListView = $factory->createView(
$choiceList,
// Preferred choices
array(),
// Label
function ($choice, $key) use ($labels) {
return $labels[$key];
}
);
```
* The "property" option of `DoctrineType` was deprecated. You should use the
new inherited option "choice_label" instead, which has the same effect.
Before:
```php
$form->add('tags', 'entity', array(
'class' => 'Acme\Entity\MyTag',
'property' => 'name',
))
```
After:
```php
$form->add('tags', 'entity', array(
'class' => 'Acme\Entity\MyTag',
'choice_label' => 'name',
))
```
* The "loader" option of `DoctrineType` was deprecated and will be removed in
Symfony 3.0. You should override the `getLoader()` method instead in a custom
type.
Before:
```php
$form->add('tags', 'entity', array(
'class' => 'Acme\Entity\MyTag',
'loader' => new MyEntityLoader(),
))
```
After:
class MyEntityType extends DoctrineType
{
// ...
public function getLoader()
{
return new MyEntityLoader();
}
}
* `Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList` was
deprecated and will be removed in Symfony 3.0. You should use
`Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader` instead.
Before:
```php
use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
$choiceList = new EntityChoiceList($em, 'Acme\Entity\MyEntity');
```
After:
```php
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
$factory = new DefaultChoiceListFactory();
$choices = array(Status::ENABLED, Status::DISABLED);
$labels = array('Enabled', 'Disabled');
$choiceLoader = new DoctrineChoiceLoader($factory, $em, 'Acme\Entity\MyEntity');
$choiceList = $factory->createListFromLoader($choiceLoader);
```
* Passing a query builder closure to `ORMQueryBuilderLoader` was deprecated and
will not be supported anymore in Symfony 3.0. You should pass resolved query
builders only.
Consequently, the arguments `$manager` and `$class` of `ORMQueryBuilderLoader`
have been deprecated as well.
Note that the "query_builder" option of `DoctrineType` *does* support
closures, but the closure is now resolved in the type instead of in the
loader.
Before:
```
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
$queryBuilder = function () {
// return QueryBuilder
};
$loader = new ORMQueryBuilderLoader($queryBuilder);
```
After:
```
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
// create $queryBuilder
$loader = new ORMQueryBuilderLoader($queryBuilder);
```
* The classes `ChoiceToBooleanArrayTransformer`,
`ChoicesToBooleanArrayTransformer`, `FixRadioInputListener` and
`FixCheckboxInputListener` were deprecated and will be removed in Symfony 3.0.
Their functionality is covered by the new classes `RadioListMapper` and
`CheckboxListMapper`.
Serializer
----------

View File

@ -1,6 +1,16 @@
CHANGELOG
=========
2.7.0
-----
* added DoctrineChoiceLoader
* deprecated EntityChoiceList
* deprecated passing a query builder closure to ORMQueryBuilderLoader
* deprecated $manager and $em arguments of ORMQueryBuilderLoader
* added optional arguments $propertyAccessor and $choiceListFactory to DoctrineOrmExtension constructor
* deprecated "loader" and "property" options of DoctrineType
2.4.0
-----

View File

@ -69,12 +69,14 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
* IDs.
* @param null|EntityLoaderInterface $objectLoader The objects loader
*/
public function __construct(ChoiceListFactoryInterface $factory, ObjectManager $manager, $class, IdReader $idReader, EntityLoaderInterface $objectLoader = null)
public function __construct(ChoiceListFactoryInterface $factory, ObjectManager $manager, $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
{
$classMetadata = $manager->getClassMetadata($class);
$this->factory = $factory;
$this->manager = $manager;
$this->class = $manager->getClassMetadata($class)->getName();
$this->idReader = $idReader;
$this->class = $classMetadata->getName();
$this->idReader = $idReader ?: new IdReader($manager, $classMetadata);
$this->objectLoader = $objectLoader;
}

View File

@ -7,6 +7,23 @@ CHANGELOG
* deprecated option "precision" in favor of "scale"
* deprecated the overwriting of AbstractType::setDefaultOptions() in favor of overwriting AbstractType::configureOptions().
* deprecated the overwriting of AbstractTypeExtension::setDefaultOptions() in favor of overwriting AbstractTypeExtension::configureOptions().
* added new ChoiceList interface and implementations in the Symfony\Component\Form\ChoiceList namespace
* added new ChoiceView in the Symfony\Component\Form\ChoiceList\View namespace
* choice groups are now represented by ChoiceGroupView objects in the view
* deprecated the old ChoiceList interface and implementations
* deprecated the old ChoiceView class
* added CheckboxListMapper and RadioListMapper
* deprecated ChoiceToBooleanArrayTransformer and ChoicesToBooleanArrayTransformer
* deprecated FixCheckboxInputListener and FixRadioInputListener
* deprecated the "choice_list" option of ChoiceType
* added new options to ChoiceType:
* "choices_as_values"
* "choice_loader"
* "choice_label"
* "choice_name"
* "choice_value"
* "choice_attr"
* "group_by"
2.6.2
-----