[Form] Updated CHANGELOG and UPGRADE files
This commit is contained in:
parent
0b39ce2315
commit
6863ba5bef
369
UPGRADE-2.7.md
369
UPGRADE-2.7.md
@ -60,6 +60,375 @@ Form
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* 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
|
Serializer
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
CHANGELOG
|
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
|
2.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -69,12 +69,14 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
|||||||
* IDs.
|
* IDs.
|
||||||
* @param null|EntityLoaderInterface $objectLoader The objects loader
|
* @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->factory = $factory;
|
||||||
$this->manager = $manager;
|
$this->manager = $manager;
|
||||||
$this->class = $manager->getClassMetadata($class)->getName();
|
$this->class = $classMetadata->getName();
|
||||||
$this->idReader = $idReader;
|
$this->idReader = $idReader ?: new IdReader($manager, $classMetadata);
|
||||||
$this->objectLoader = $objectLoader;
|
$this->objectLoader = $objectLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,23 @@ CHANGELOG
|
|||||||
|
|
||||||
* deprecated the overwriting of AbstractType::setDefaultOptions() in favor of overwriting AbstractType::configureOptions().
|
* deprecated the overwriting of AbstractType::setDefaultOptions() in favor of overwriting AbstractType::configureOptions().
|
||||||
* deprecated the overwriting of AbstractTypeExtension::setDefaultOptions() in favor of overwriting AbstractTypeExtension::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
|
2.6.2
|
||||||
-----
|
-----
|
||||||
|
Reference in New Issue
Block a user