synchronize 2.8 and 3.0 upgrade files

This commit is contained in:
Christian Flothmann 2016-01-16 19:39:57 +01:00
parent 617bf78b17
commit ab98bc1486

View File

@ -20,6 +20,13 @@ UPGRADE FROM 2.x to 3.0
`DebugClassLoader`. The difference is that the constructor now takes a `DebugClassLoader`. The difference is that the constructor now takes a
loader to wrap. loader to wrap.
### Config
* `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` has been removed. Also,
cache validation through this method (which was still supported in 2.8 for BC) does no longer
work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class
has been removed as well.
### Console ### Console
* The `dialog` helper has been removed in favor of the `question` helper. * The `dialog` helper has been removed in favor of the `question` helper.
@ -90,6 +97,79 @@ UPGRADE FROM 2.x to 3.0
### DependencyInjection ### DependencyInjection
* The concept of scopes was removed, the removed methods are:
- `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()`
- `Symfony\Component\DependencyInjection\ContainerBuilder::getScopeChildren()`
- `Symfony\Component\DependencyInjection\ContainerInterface::enterScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::leaveScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::addScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::hasScope()`
- `Symfony\Component\DependencyInjection\ContainerInterface::isScopeActive()`
- `Symfony\Component\DependencyInjection\Definition::setScope()`
- `Symfony\Component\DependencyInjection\Definition::getScope()`
- `Symfony\Component\DependencyInjection\Reference::isStrict()`
Also, the `$scope` and `$strict` parameters of `Symfony\Component\DependencyInjection\ContainerInterface::set()`
and `Symfony\Component\DependencyInjection\Reference` respectively were removed.
* A new `shared` flag has been added to the service definition
in replacement of the `prototype` scope.
Before:
```php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'stdClass')
->setScope(ContainerBuilder::SCOPE_PROTOTYPE)
;
```
```yml
services:
foo:
class: stdClass
scope: prototype
```
```xml
<services>
<service id="foo" class="stdClass" scope="prototype" />
</services>
```
After:
```php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'stdClass')
->setShared(false)
;
```
```yml
services:
foo:
class: stdClass
shared: false
```
```xml
<services>
<service id="foo" class="stdClass" shared="false" />
</services>
```
* `Symfony\Component\DependencyInjection\ContainerAware` was removed, use
`Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement
`Symfony\Component\DependencyInjection\ContainerAwareInterface` manually
* The methods `Definition::setFactoryClass()`, * The methods `Definition::setFactoryClass()`,
`Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have `Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have
been removed in favor of `Definition::setFactory()`. Services defined using been removed in favor of `Definition::setFactory()`. Services defined using
@ -106,12 +186,170 @@ UPGRADE FROM 2.x to 3.0
### Form ### Form
* The option `options` of the `CollectionType` has been removed in favor
of the `entry_options` option.
* The `cascade_validation` option was removed. Use the `constraints` option
together with the `Valid` constraint instead.
* Type names were removed. Instead of referencing types by name, you must
reference them by their fully-qualified class name (FQCN) instead:
Before:
```php
$form = $this->createFormBuilder()
->add('name', 'text')
->add('age', 'integer')
->getForm();
```
After:
```php
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
$form = $this->createFormBuilder()
->add('name', TextType::class)
->add('age', IntegerType::class)
->getForm();
```
If you want to customize the block prefix of a type in Twig, you must now
implement `FormTypeInterface::getBlockPrefix()`:
Before:
```php
class UserProfileType extends AbstractType
{
public function getName()
{
return 'profile';
}
}
```
After:
```php
class UserProfileType extends AbstractType
{
public function getBlockPrefix()
{
return 'profile';
}
}
```
If you don't customize `getBlockPrefix()`, it defaults to the class name
without "Type" suffix in underscore notation (here: "user_profile").
Type extension must return the fully-qualified class name of the extended
type from `FormTypeExtensionInterface::getExtendedType()` now.
Before:
```php
class MyTypeExtension extends AbstractTypeExtension
{
public function getExtendedType()
{
return 'form';
}
}
```
After:
```php
use Symfony\Component\Form\Extension\Core\Type\FormType;
class MyTypeExtension extends AbstractTypeExtension
{
public function getExtendedType()
{
return FormType::class;
}
}
```
* The `FormTypeInterface::getName()` method was removed.
* Returning type instances from `FormTypeInterface::getParent()` is not
supported anymore. Return the fully-qualified class name of the parent
type class instead.
Before:
```php
class MyType
{
public function getParent()
{
return new ParentType();
}
}
```
After:
```php
class MyType
{
public function getParent()
{
return ParentType::class;
}
}
```
* The option `type` of the `CollectionType` has been removed in favor of
the `entry_type` option. The value for the `entry_type` option must be
the fully-qualified class name (FQCN).
* Passing type instances to `Form::add()`, `FormBuilder::add()` and the
`FormFactory::create*()` methods is not supported anymore. Pass the
fully-qualified class name of the type instead.
Before:
```php
$form = $this->createForm(new MyType());
```
After:
```php
$form = $this->createForm(MyType::class);
```
* The alias option of the `form.type_extension` tag was removed in favor of
the `extended_type`/`extended-type` option.
Before:
```xml
<service id="app.type_extension" class="Vendor\Form\Extension\MyTypeExtension">
<tag name="form.type_extension" alias="text" />
</service>
```
After:
```xml
<service id="app.type_extension" class="Vendor\Form\Extension\MyTypeExtension">
<tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\TextType" />
</service>
```
* The option "precision" was renamed to "scale". * The option "precision" was renamed to "scale".
Before: Before:
```php ```php
$builder->add('length', 'number', array( use Symfony\Component\Form\Extension\Core\Type\NumberType;
$builder->add('length', NumberType::class, array(
'precision' => 3, 'precision' => 3,
)); ));
``` ```
@ -119,7 +357,9 @@ UPGRADE FROM 2.x to 3.0
After: After:
```php ```php
$builder->add('length', 'number', array( use Symfony\Component\Form\Extension\Core\Type\NumberType;
$builder->add('length', NumberType::class, array(
'scale' => 3, 'scale' => 3,
)); ));
``` ```
@ -129,7 +369,9 @@ UPGRADE FROM 2.x to 3.0
Before: Before:
```php ```php
$builder->add('address', 'form', array( use Symfony\Component\Form\Extension\Core\Type\FormType;
$builder->add('address', FormType::class, array(
'virtual' => true, 'virtual' => true,
)); ));
``` ```
@ -137,7 +379,9 @@ UPGRADE FROM 2.x to 3.0
After: After:
```php ```php
$builder->add('address', 'form', array( use Symfony\Component\Form\Extension\Core\Type\FormType;
$builder->add('address', FormType::class, array(
'inherit_data' => true, 'inherit_data' => true,
)); ));
``` ```
@ -264,12 +508,12 @@ UPGRADE FROM 2.x to 3.0
// ... // ...
} }
``` ```
* The option "options" of the CollectionType has been renamed to "entry_options". * The option "options" of the CollectionType has been renamed to "entry_options".
* The option "type" of the CollectionType has been renamed to "entry_type". * The option "type" of the CollectionType has been renamed to "entry_type".
As a value for the option you must provide the fully-qualified class name (FQCN) As a value for the option you must provide the fully-qualified class name (FQCN)
now as well. now as well.
* The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. * The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace.
@ -317,8 +561,8 @@ UPGRADE FROM 2.x to 3.0
* The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in * The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in
favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`.
* The `TimezoneType::getTimezones()` method was removed. You should not use * The `TimezoneType::getTimezones()` method was removed. You should not use
this method. this method.
* The `Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList` class has been removed in * The `Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList` class has been removed in
@ -365,11 +609,11 @@ UPGRADE FROM 2.x to 3.0
} }
} }
``` ```
* In Symfony 2.7 a small BC break was introduced with the new choices_as_values * In Symfony 2.7 a small BC break was introduced with the new choices_as_values
option. In order to have the choice values populated to the html value attribute option. In order to have the choice values populated to the html value attribute
you had to define the choice_value option. This is now not any more needed. you had to define the choice_value option. This is now not any more needed.
Before: Before:
```php ```php
@ -389,9 +633,9 @@ UPGRADE FROM 2.x to 3.0
}, },
)); ));
``` ```
After: After:
```php ```php
$form->add('status', ChoiceType::class, array( $form->add('status', ChoiceType::class, array(
'choices' => array( 'choices' => array(
@ -400,7 +644,7 @@ UPGRADE FROM 2.x to 3.0
'Ignored' => Status::IGNORED, 'Ignored' => Status::IGNORED,
) )
)); ));
``` ```
* The `request` service was removed. You must inject the `request_stack` * The `request` service was removed. You must inject the `request_stack`
service instead. service instead.
@ -647,6 +891,11 @@ UPGRADE FROM 2.x to 3.0
### Security ### Security
* The `AbstractVoter` class was removed in favor of the new `Voter` class.
* The `VoterInterface::supportsClass` and `supportsAttribute` methods were
removed from the interface.
* The `Resources/` directory was moved to `Core/Resources/` * The `Resources/` directory was moved to `Core/Resources/`
* The `key` settings of `anonymous`, `remember_me` and `http_digest` are * The `key` settings of `anonymous`, `remember_me` and `http_digest` are
@ -779,6 +1028,10 @@ UPGRADE FROM 2.x to 3.0
* The `Translator::setFallbackLocale()` method has been removed in favor of * The `Translator::setFallbackLocale()` method has been removed in favor of
`Translator::setFallbackLocales()`. `Translator::setFallbackLocales()`.
* The `getMessages()` method of the `Symfony\Component\Translation\Translator`
class was removed. You should use the `getCatalogue()` method of the
`Symfony\Component\Translation\TranslatorBagInterface`.
### Twig Bridge ### Twig Bridge
* The `twig:lint` command has been deprecated since Symfony 2.7 and will be * The `twig:lint` command has been deprecated since Symfony 2.7 and will be
@ -1308,15 +1561,25 @@ UPGRADE FROM 2.x to 3.0
Yaml::parse(file_get_contents($fileName)); Yaml::parse(file_get_contents($fileName));
``` ```
### WebProfiler
* The `profiler:import` and `profiler:export` commands have been deprecated and
will be removed in 3.0.
* All the profiler storages different than `FileProfilerStorage` have been
removed. The removed classes are:
- `Symfony\Component\HttpKernel\Profiler\BaseMemcacheProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\PdoProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage`
- `Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage`
### Process ### Process
* `Process::setStdin()` and `Process::getStdin()` have been removed. Use * `Process::setStdin()` and `Process::getStdin()` have been removed. Use
`Process::setInput()` and `Process::getInput()` that works the same way. `Process::setInput()` and `Process::getInput()` that works the same way.
* `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types.
### Config
* `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` has been removed. Also,
cache validation through this method (which was still supported in 2.8 for BC) does no longer
work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class
has been removed as well.