8000 [DoctrineBridge] added a bc layer for #18069 · symfony/symfony@81f1a80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81f1a80

Browse files
committed
[DoctrineBridge] added a bc layer for #18069
1 parent 352997e commit 81f1a80

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,32 @@
2727
*/
2828
class MergeDoctrineCollectionListener implements EventSubscriberInterface
2929
{
30-
// Keeps BC. To be removed in 4.0
30+
// Keep BC. To be removed in 4.0
3131
private $bc = true;
32+
private $bcLayer = false;
3233

3334
public static function getSubscribedEvents()
3435
{
3536
// Higher priority than core MergeCollectionListener so that this one
3637
// is called before
3738
return array(
3839
FormEvents::SUBMIT => array(
39-
// BC
40-
array('onBind', 10),
40+
array('onBind', 10), // deprecated
4141
array('onSubmit', 5),
4242
),
4343
);
4444
}
4545

4646
public function onSubmit(FormEvent $event)
4747
{
48-
// If onBind() is overridden then logic has been executed
4948
if ($this->bc) {
49+
// onBind() has been overridden from a child class
5050
@trigger_error('The onBind() method is deprecated since version 3.1 and will be removed in 4.0. Use the onSubmit() method instead.', E_USER_DEPRECATED);
5151

52-
return;
52+
if (!$this->bcLayer) {
53+
// If parent::onBind() has not been called, then logic has been executed
54+
return;
55+
}
5356
}
5457

5558
$collection = $event->getForm()->getData();
@@ -72,6 +75,9 @@ public function onBind()
7275
{
7376
if (__CLASS__ === get_class($this)) {
7477
$this->bc = false;
78+
} else {
79+
// parent::onBind() has been called
80+
$this->bcLayer = true;
7581
}
7682
}
7783
}

0 commit comments

Comments
 (0)
0