synchronize 2.8 and 3.0 upgrade files
This commit is contained in:
parent
617bf78b17
commit
ab98bc1486
285
UPGRADE-3.0.md
285
UPGRADE-3.0.md
@ -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,
|
||||||
));
|
));
|
||||||
```
|
```
|
||||||
@ -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.
|
|
||||||
|
Reference in New Issue
Block a user