2013-01-15 07:06:36 +00:00
|
|
|
UPGRADE FROM 2.x to 3.0
|
|
|
|
=======================
|
|
|
|
|
2013-02-08 13:02:12 +00:00
|
|
|
### ClassLoader
|
|
|
|
|
2013-03-20 17:09:46 +00:00
|
|
|
* The `UniversalClassLoader` class has been removed in favor of
|
|
|
|
`ClassLoader`. The only difference is that some method names are different:
|
2013-02-08 13:02:12 +00:00
|
|
|
|
|
|
|
* `registerNamespaces()` -> `addPrefixes()`
|
|
|
|
* `registerPrefixes()` -> `addPrefixes()`
|
|
|
|
* `registerNamespaces()` -> `addPrefix()`
|
|
|
|
* `registerPrefixes()` -> `addPrefix()`
|
|
|
|
* `getNamespaces()` -> `getPrefixes()`
|
|
|
|
* `getNamespaceFallbacks()` -> `getFallbackDirs()`
|
|
|
|
* `getPrefixFallbacks()` -> `getFallbackDirs()`
|
|
|
|
|
|
|
|
* The `DebugUniversalClassLoader` class has been removed in favor of
|
|
|
|
`DebugClassLoader`. The difference is that the constructor now takes a
|
|
|
|
loader to wrap.
|
|
|
|
|
2013-04-17 17:47:21 +01:00
|
|
|
### Form
|
|
|
|
|
|
|
|
* Passing a `Symfony\Component\HttpFoundation\Request` instance to
|
|
|
|
`FormInterface::bind()` was disabled. You should use
|
|
|
|
`FormInterface::process()` instead.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
if ('POST' === $request->getMethod()) {
|
|
|
|
$form->bind($request);
|
|
|
|
|
|
|
|
if ($form->isValid()) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
if ($form->process($request)->isValid()) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
If you want to test whether the form was submitted separately, you can use
|
|
|
|
the method `isBound()`:
|
|
|
|
|
|
|
|
```
|
|
|
|
if ($form->process($request)->isBound()) {
|
|
|
|
// ...
|
|
|
|
|
|
|
|
if ($form->isValid()) {
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2013-01-04 15:34:38 +00:00
|
|
|
* The option "virtual" was renamed to "inherit_data".
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
$builder->add('address', 'form', array(
|
|
|
|
'virtual' => true,
|
|
|
|
));
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
$builder->add('address', 'form', array(
|
|
|
|
'inherit_data' => true,
|
|
|
|
));
|
|
|
|
```
|
|
|
|
|
|
|
|
* The class VirtualFormAwareIterator was renamed to InheritDataAwareIterator.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
use Symfony\Component\Form\Util\VirtualFormAwareIterator;
|
|
|
|
|
|
|
|
$iterator = new VirtualFormAwareIterator($forms);
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
use Symfony\Component\Form\Util\InheritDataAwareIterator;
|
|
|
|
|
|
|
|
$iterator = new InheritDataAwareIterator($forms);
|
|
|
|
```
|
|
|
|
|
2013-04-17 17:47:21 +01:00
|
|
|
### FrameworkBundle
|
|
|
|
|
|
|
|
* The `enctype` method of the `form` helper was removed. You should use the
|
|
|
|
new method `start` instead.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
<form method="post" action="http://example.com" <?php echo $view['form']->enctype($form) ?>>
|
|
|
|
...
|
|
|
|
</form>
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
<?php echo $view['form']->start($form) ?>
|
|
|
|
...
|
|
|
|
<?php echo $view['form']->end($form) ?>
|
|
|
|
```
|
|
|
|
|
|
|
|
The method and action of the form default to "POST" and the current
|
|
|
|
document. If you want to change these values, you can set them explicitly in
|
|
|
|
the controller.
|
|
|
|
|
|
|
|
Alternative 1:
|
|
|
|
|
|
|
|
```
|
|
|
|
$form = $this->createForm('my_form', $formData, array(
|
|
|
|
'method' => 'PUT',
|
|
|
|
'action' => $this->generateUrl('target_route'),
|
|
|
|
));
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternative 2:
|
|
|
|
|
|
|
|
```
|
|
|
|
$form = $this->createFormBuilder($formData)
|
|
|
|
// ...
|
|
|
|
->setMethod('PUT')
|
|
|
|
->setAction($this->generateUrl('target_route'))
|
|
|
|
->getForm();
|
|
|
|
```
|
|
|
|
|
|
|
|
It is also possible to override the method and the action in the template:
|
|
|
|
|
|
|
|
```
|
|
|
|
<?php echo $view['form']->start($form, array('method' => 'GET', 'action' => 'http://example.com')) ?>
|
|
|
|
...
|
|
|
|
<?php echo $view['form']->end($form) ?>
|
|
|
|
```
|
|
|
|
|
2013-01-16 22:09:43 +00:00
|
|
|
### HttpKernel
|
|
|
|
|
|
|
|
* The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in
|
|
|
|
favor of `Psr\Log\LoggerInterface`. The only difference is that some method
|
|
|
|
names are different:
|
|
|
|
|
2013-01-17 14:01:21 +00:00
|
|
|
* `emerg()` -> `emergency()`
|
|
|
|
* `crit()` -> `critical()`
|
|
|
|
* `err()` -> `error()`
|
|
|
|
* `warn()` -> `warning()`
|
2013-01-16 22:09:43 +00:00
|
|
|
|
|
|
|
The previous method renames also happened to the following classes:
|
|
|
|
|
2013-01-17 14:01:21 +00:00
|
|
|
* `Symfony\Bridge\Monolog\Logger`
|
|
|
|
* `Symfony\Component\HttpKernel\Log\NullLogger`
|
2013-01-16 22:09:43 +00:00
|
|
|
|
2013-03-20 17:09:46 +00:00
|
|
|
* The `Symfony\Component\HttpKernel\Kernel::init()` method has been removed.
|
|
|
|
|
|
|
|
* The following classes have been renamed as they have been moved to the
|
|
|
|
Debug component:
|
|
|
|
|
|
|
|
* `Symfony\Component\HttpKernel\Debug\ErrorHandler` -> `Symfony\Component\Debug\ErrorHandler`
|
|
|
|
* `Symfony\Component\HttpKernel\Debug\ExceptionHandler` -> `Symfony\Component\Debug\ExceptionHandler`
|
|
|
|
* `Symfony\Component\HttpKernel\Exception\FatalErrorException` -> `Symfony\Component\Debug\Exception\FatalErrorException`
|
|
|
|
* `Symfony\Component\HttpKernel\Exception\FlattenException` -> `Symfony\Component\Debug\Exception\FlattenException`
|
|
|
|
|
2013-01-15 07:06:36 +00:00
|
|
|
### Routing
|
|
|
|
|
|
|
|
* Some route settings have been renamed:
|
|
|
|
|
2013-01-17 14:01:21 +00:00
|
|
|
* The `pattern` setting for a route has been deprecated in favor of `path`
|
|
|
|
* The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings
|
2013-01-15 07:06:36 +00:00
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
article_edit:
|
|
|
|
pattern: /article/{id}
|
|
|
|
requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' }
|
|
|
|
|
|
|
|
<route id="article_edit" pattern="/article/{id}">
|
|
|
|
<requirement key="_method">POST|PUT</requirement>
|
|
|
|
<requirement key="_scheme">https</requirement>
|
|
|
|
<requirement key="id">\d+</requirement>
|
|
|
|
</route>
|
|
|
|
|
|
|
|
$route = new Route();
|
|
|
|
$route->setPattern('/article/{id}');
|
|
|
|
$route->setRequirement('_method', 'POST|PUT');
|
|
|
|
$route->setRequirement('_scheme', 'https');
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
article_edit:
|
|
|
|
path: /article/{id}
|
|
|
|
methods: [POST, PUT]
|
|
|
|
schemes: https
|
|
|
|
requirements: { 'id': '\d+' }
|
|
|
|
|
2013-01-15 18:31:20 +00:00
|
|
|
<route id="article_edit" path="/article/{id}" methods="POST PUT" schemes="https">
|
2013-01-15 07:06:36 +00:00
|
|
|
<requirement key="id">\d+</requirement>
|
|
|
|
</route>
|
|
|
|
|
|
|
|
$route = new Route();
|
|
|
|
$route->setPath('/article/{id}');
|
|
|
|
$route->setMethods(array('POST', 'PUT'));
|
|
|
|
$route->setSchemes('https');
|
|
|
|
```
|
2013-01-17 14:01:21 +00:00
|
|
|
|
2013-02-17 17:30:02 +00:00
|
|
|
### Translator
|
|
|
|
|
|
|
|
* The `Translator::setFallbackLocale()` method has been removed in favor of
|
|
|
|
`Translator::setFallbackLocales()`.
|
|
|
|
|
2013-01-28 17:29:00 +00:00
|
|
|
### Twig Bridge
|
|
|
|
|
|
|
|
* The `render` tag is deprecated in favor of the `render` function.
|
|
|
|
|
2013-04-17 17:47:21 +01:00
|
|
|
* The `form_enctype` helper was removed. You should use the new `form_start`
|
|
|
|
function instead.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
<form method="post" action="http://example.com" {{ form_enctype(form) }}>
|
|
|
|
...
|
|
|
|
</form>
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
{{ form_start(form) }}
|
|
|
|
...
|
|
|
|
{{ form_end(form) }}
|
|
|
|
```
|
|
|
|
|
|
|
|
The method and action of the form default to "POST" and the current
|
|
|
|
document. If you want to change these values, you can set them explicitly in
|
|
|
|
the controller.
|
|
|
|
|
|
|
|
Alternative 1:
|
|
|
|
|
|
|
|
```
|
|
|
|
$form = $this->createForm('my_form', $formData, array(
|
|
|
|
'method' => 'PUT',
|
|
|
|
'action' => $this->generateUrl('target_route'),
|
|
|
|
));
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternative 2:
|
|
|
|
|
|
|
|
```
|
|
|
|
$form = $this->createFormBuilder($formData)
|
|
|
|
// ...
|
|
|
|
->setMethod('PUT')
|
|
|
|
->setAction($this->generateUrl('target_route'))
|
|
|
|
->getForm();
|
|
|
|
```
|
|
|
|
|
|
|
|
It is also possible to override the method and the action in the template:
|
|
|
|
|
|
|
|
```
|
|
|
|
{{ form_start(form, {'method': 'GET', 'action': 'http://example.com'}) }}
|
|
|
|
...
|
|
|
|
{{ form_end(form) }}
|
|
|
|
```
|
|
|
|
|
2013-01-17 14:01:21 +00:00
|
|
|
### Yaml
|
|
|
|
|
|
|
|
* The ability to pass file names to `Yaml::parse()` has been removed.
|
|
|
|
|
|
|
|
Before:
|
|
|
|
|
|
|
|
```
|
|
|
|
Yaml::parse($fileName);
|
|
|
|
```
|
|
|
|
|
|
|
|
After:
|
|
|
|
|
|
|
|
```
|
|
|
|
Yaml::parse(file_get_contents($fileName));
|
|
|
|
```
|