8000 [Form] Remove deprecations in form events by HeahDude · Pull Request #51076 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Remove deprecations in form events #51076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Form] Remove deprecations in form events
  • Loading branch information
HeahDude committed Jul 24, 2023
commit 87c91fb81b47461239dffa97f399fdb090aa4b1f
2 changes: 2 additions & 0 deletions UPGRADE-7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Form
`model_timezone` option in `DateType`, `DateTimeType`, and `TimeType`
* Make the "widget" option of date/time form types default to "single_text"
* Require explicit argument when calling `Button/Form::setParent()`, `ButtonBuilder/FormConfigBuilder::setDataMapper()`, `TransformationFailedException::setInvalidMessage()`
* `PostSetDataEvent::setData()` throws an exception, use `PreSetDataEvent::setData()` instead
* `PostSubmitEvent::setData()` throws an exception, use `PreSubmitDataEvent::setData()` or `SubmitDataEvent::setData()` instead

FrameworkBundle
---------------
Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/Form/Event/PostSetDataEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
*/
final class PostSetDataEvent extends FormEvent
{
/**
* @deprecated since Symfony 6.4, it will throw an exception in 7.0.
*/
public function setData(mixed $data): void
{
trigger_deprecation('symfony/form', '6.4', 'Calling "%s()" will throw an exception as of 7.0, listen to "form.pre_set_data" instead.', __METHOD__);
// throw new BadMethodCallException('Form data cannot be changed during "form.post_set_data", you should use "form.pre_set_data" instead.');
throw new BadMethodCallException('Form data cannot be changed during "form.post_set_data", you should use "form.pre_set_data" instead.');
}
}
7 changes: 2 additions & 5 deletions src/Symfony/Component/Form/Event/PostSubmitEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Form\Event;

use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\FormEvent;

/**
Expand All @@ -21,12 +22,8 @@
*/
final class PostSubmitEvent extends FormEvent
{
/**
* @deprecated since Symfony 6.4, it will throw an exception in 7.0.
*/
public function setData(mixed $data): void
{
trigger_deprecation('symfony/form', '6.4', 'Calling "%s()" will throw an exception as of 7.0, listen to "form.pre_submit" or "form.submit" instead.', __METHOD__);
// throw new BadMethodCallException('Form data cannot be changed during "form.post_submit", you should use "form.pre_submit" or "form.submit" instead.');
throw new BadMethodCallException('Form data cannot be changed during "form.post_submit", you should use "form.pre_submit" or "form.submit" instead.');
}
}
0