E577 Add FormConfigInterface::getIsEmptyCallback() · symfony/symfony@da0f36f · GitHub
[go: up one dir, main page]

Skip to content

Commit da0f36f

Browse files
committed
Add FormConfigInterface::getIsEmptyCallback()
1 parent 1001aae commit da0f36f

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Remove `PropertyPathMaper`
88
* Remove `Symfony\Component\Form\Extension\Validator\Util\ServiceParams`
99
* Remove `FormPass` configuration
10+
* Add `FormConfigInterface::getIsEmptyCallback()` and `FormConfigBuilderInterface::setIsEmptyCallback()`
1011

1112
5.3
1213
---

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6666
$builder->addEventSubscriber(new TrimListener());
6767
}
6868

69-
if (!method_exists($builder, 'setIsEmptyCallback')) {
70-
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::setIsEmptyCallback()" method in "%s" is deprecated.', FormConfigBuilderInterface::class, get_debug_type($builder));
71-
72-
return;
73-
}
74-
7569
$builder->setIsEmptyCallback($options['is_empty_callback']);
7670
}
7771

src/Symfony/Component/Form/Form.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,7 @@ public function isEmpty()
724724
}
725725
}
726726

727-
if (!method_exists($this->config, 'getIsEmptyCallback')) {
728-
trigger_deprecation('symfony/form', '5.1', 'Not implementing the "%s::getIsEmptyCallback()" method in "%s" is deprecated.', FormConfigInterface::class, \get_class($this->config));
729-
730-
$isEmptyCallback = null;
731-
} else {
732-
$isEmptyCallback = $this->config->getIsEmptyCallback();
733-
}
734-
735-
if (null !== $isEmptyCallback) {
727+
if (null !== $isEmptyCallback = $this->config->getIsEmptyCallback()) {
736728
return $isEmptyCallback($this->modelData);
737729
}
738730

src/Symfony/Component/Form/FormConfigBuilderInterface.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
/**
1818
* @author Bernhard Schussek <bschussek@gmail.com>
19-
*
20-
* @method $this setIsEmptyCallback(callable|null $isEmptyCallback) Sets the callback that will be called to determine if the model data of the form is empty or not - not implementing it is deprecated since Symfony 5.1
2119
*/
2220
interface FormConfigBuilderInterface extends FormConfigInterface
2321
{
@@ -251,4 +249,12 @@ public function setAutoInitialize(bool $initialize);
251249
* @return FormConfigInterface
252250
*/
253251
public function getFormConfig();
252+
253+
/**
254+
* Sets the callback that will be called to determine if the model
255+
* data of the form is empty or not.
256+
*
257+
* @return $this The configuration object
258+
*/
259+
public function setIsEmptyCallback(?callable $isEmptyCallback);
254260
}

src/Symfony/Component/Form/FormConfigInterface.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
* The configuration of a {@link Form} object.
1919
*
2020
* @author Bernhard Schussek <bschussek@gmail.com>
21-
*
22-
* @method callable|null getIsEmptyCallback() Returns a callable that takes the model data as argument and that returns if it is empty or not - not implementing it is deprecated since Symfony 5.1
2321
*/
2422
interface FormConfigInterface
2523
{
@@ -247,4 +245,9 @@ public function hasOption(string $name);
247245
* @return mixed The option value
248246
*/
249247
public function getOption(string $name, $default = null);
248+
249+
/**
250+
* Returns a callable that takes the model data as argument and that returns if it is empty or not.
251+
*/
252+
public function getIsEmptyCallback(): ?callable;
250253
}

0 commit comments

Comments
 (0)
0