You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MongoDbSessionHandler default field names and timestamp type have changed.
The sess_ prefix was removed from default field names. The session ID is
now stored in the _id field by default. The session date is now stored as a
MongoDate instead of MongoTimestamp, which also makes it possible to use
TTL collections in MongoDB 2.2+ instead of relying on the gc() method.
The Stopwatch functionality was moved from HttpKernel\Debug to its own component
The _method request parameter support has been disabled by default (call
Request::enableHttpMethodParameterOverride() to enable it).
Deprecations
The Request::splitHttpAcceptHeader() is deprecated and will be removed in 2.3.
You should now use the AcceptHeader class which give you fluent methods to
parse request accept-* headers. Some examples:
$accept = AcceptHeader::fromString($request->headers->get('Accept'));
if ($accept->has('text/html') {
$item = $accept->get('html');
$charset = $item->getAttribute('charset', 'utf-8');
$quality = $item->getQuality();
}
// accepts items are sorted by descending quality$accepts = AcceptHeader::fromString($request->headers->get('Accept'))->all();
Form
The PasswordType is now not trimmed by default.
The class FormException is now an interface. The old class is still available
under the name Symfony\Component\Form\Exception\Exception, but will probably
be removed before 2.2. If you created FormException instances manually,
you are now advised to create any of the other exceptions in the
Symfony\Component\Form\Exception namespace or to create custom exception
classes for your purpose.
Translating validation errors is now optional. You can still do so
manually if you like, or you can simplify your templates to simply output
the already translated message.
FormType, ModelType and PropertyPathMapper now have constructors. If you
extended these classes, you should call the parent constructor now.
Note that you are not recommended to extend FormType nor ModelType. You should
extend AbstractType instead and use the Form component's own inheritance
mechanism (AbstractType::getParent()).
The methods getParent(), setParent() and hasParent() in
FormBuilderInterface were deprecated and will be removed in Symfony 2.3.
You should not rely on these methods in your form type because the parent
of a form can change after building it.
The class PropertyPath and related classes were deprecated and moved to a
dedicated component PropertyAccess. If you used any of these classes or
interfaces, you should adapt the namespaces now. During the move,
InvalidPropertyException was renamed to NoSuchPropertyException.
RouteCollection does not behave like a tree structure anymore but as a flat
array of Routes. So when using PHP to build the RouteCollection, you must
make sure to add routes to the sub-collection before adding it to the parent
collection (this is not relevant when using YAML or XML for Route definitions).
The methods RouteCollection::getParent() and RouteCollection::getRoot()
have been deprecated and will be removed in Symfony 2.3.
Misusing the RouteCollection::addPrefix method to add defaults, requirements
or options without adding a prefix is not supported anymore. So if you called addPrefix
with an empty prefix or / only (both have no relevance), like
addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)
you need to use the new dedicated methods addDefaults($defaultsArray),
addRequirements($requirementsArray) or addOptions($optionsArray) instead.
The $options parameter to RouteCollection::addPrefix() has been deprecated
because adding options has nothing to do with adding a path prefix. If you want to add options
to all child routes of a RouteCollection, you can use addOptions().
The method RouteCollection::getPrefix() has been deprecated
because it suggested that all routes in the collection would have this prefix, which is
not necessarily true. On top of that, since there is no tree structure anymore, this method
is also useless.
RouteCollection::addCollection(RouteCollection $collection) should now only be
used with a single parameter. The other params $prefix, $default, $requirements and $options
will still work, but have been deprecated. The addPrefix method should be used for this
use-case instead.
Before: $parentCollection->addCollection($collection, '/prefix', array(...), array(...))
After:
Interfaces were created for the classes ConstraintViolation,
ConstraintViolationList, GlobalExecutionContext and ExecutionContext.
If you type hinted against any of these classes, you are recommended to
type hint against their interfaces now.
The sources of the pluralized messages in translation files have changed
from the singular to the pluralized version. If you created custom
translation files for validator errors, you should adapt them.
Before:
You must select at least {{ limit }} choices.
Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.
After:
You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.
Sie müssen mindestens {{ limit }} Möglichkeit wählen.|Sie müssen mindestens {{ limit }} Möglichkeiten wählen.
Check the file src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
for the new message sources.
Deprecations
The interface ClassMetadataFactoryInterface was deprecated and will be
removed in Symfony 2.3. You should implement MetadataFactoryInterface
instead, which changes the name of the method getClassMetadata to
getMetadataFor and accepts arbitrary values (e.g. class names, objects,
numbers etc.). In your implementation, you should throw a
NoSuchMetadataException if you don't support metadata for the given value.
useSymfony\Component\Validator\MetadataFactoryInterface;
useSymfony\Component\Validator\Exception\NoSuchMetadataException;
class MyMetadataFactory implements MetadataFactoryInterface
{
publicfunctiongetMetadataFor($value)
{
if (is_object($value)) {
$value = get_class($value);
}
if (!is_string($value) || (!class_exists($value) && !interface_exists($value))) {
thrownewNoSuchMetadataException(...);
}
// ...
}
}
The return value of ValidatorInterface::getMetadataFactory() was also
changed to return MetadataFactoryInterface. Make sure to replace calls to
getClassMetadata by getMetadataFor on the return value of this method.
The class GraphWalker and the accessor ExecutionContext::getGraphWalker()
were deprecated and will be removed in Symfony 2.3. You should use the
methods ExecutionContextInterface::validate() and
ExecutionContextInterface::validateValue() instead.
The methods ExecutionContext::addViolationAtSubPath() and
ExecutionContext::addViolationAtPath() were deprecated and will be
removed in Symfony 2.3. You should use addViolationAt() instead.
Before:
useSymfony\Component\Validator\ExecutionContext;
publicfunctionvalidateCustomLogic(ExecutionContext$context)
{
if (/* ... */) {
$context->addViolationAtSubPath('myProperty', 'This value is invalid');
}
}
After:
useSymfony\Component\Validator\ExecutionContextInterface;
publicfunctionvalidateCustomLogic(ExecutionContextInterface$context)
{
if (/* ... */) {
$context->addViolationAt('myProperty', 'This value is invalid');
}
}
The methods ExecutionContext::getCurrentClass(), ExecutionContext::getCurrentProperty()
and ExecutionContext::getCurrentValue() were deprecated and will be removed
in Symfony 2.3. Use the methods getClassName(), getPropertyName() and
getValue() instead.
The new UserPassword validator constraint class now accepts a new
service option that allows to specify a custom validator service name in
order to validate the current logged-in user's password.
The two previous UserPassword and UserPasswordValidator classes in
the Symfony\Component\Security\Core\Validator\Constraint namespace have
been deprecated and will be removed in 2.3.
All serializer interfaces (Serializer, Normalizer, Encoder) have been
extended with an optional $context array. This was necessary to allow for
more complex use-cases that require context information during the
(de)normalization and en-/decoding steps.
HttpKernel
The Symfony\Component\HttpKernel\Log\LoggerInterface now extends Psr\Log\LoggerInterface.
So if you have implemented your own logger, you need to implement these methods:
emergency
critical
error
warning
log
Deprecations:
The following Logger methods are deprecated and will be removed in 3.0. You should use the new PSR-3 methods: