Skip to content

Commit d4a2a67

Browse files
JamalXWB
authored andcommitted
Add LegacyEventDispatcherProxy for BC support (#1537)
* Add LegacyEventDispatcherProxy for BC support * Update .gitignore * add LegacyEventDispatcherProxy to resetter and other classes * LegacyEventDispatcherProxy #issuecomment-505335075
1 parent 73826f9 commit d4a2a67

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

src/Command/PopulateCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Symfony\Component\Console\Output\OutputInterface;
3333
use Symfony\Component\Console\Question\Question;
3434
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
35+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
3536

3637
/**
3738
* Populate the search index.
@@ -80,6 +81,11 @@ public function __construct(
8081
parent::__construct();
8182

8283
$this->dispatcher = $dispatcher;
84+
85+
if (class_exists(LegacyEventDispatcherProxy::class)) {
86+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
87+
}
88+
8389
$this->indexManager = $indexManager;
8490
$this->pagerProviderRegistry = $pagerProviderRegistry;
8591
$this->pagerPersisterRegistry = $pagerPersisterRegistry;

src/Doctrine/RegisterListenersService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use FOS\ElasticaBundle\Persister\Event\PersistEvent;
99
use FOS\ElasticaBundle\Provider\PagerInterface;
1010
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
11+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1112

1213
class RegisterListenersService
1314
{
@@ -19,6 +20,10 @@ class RegisterListenersService
1920
public function __construct(EventDispatcherInterface $dispatcher)
2021
{
2122
$this->dispatcher = $dispatcher;
23+
24+
if (class_exists(LegacyEventDispatcherProxy::class)) {
25+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
26+
}
2227
}
2328

2429
public function register(ObjectManager $manager, PagerInterface $pager, array $options)

src/Index/Resetter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use FOS\ElasticaBundle\Event\IndexResetEvent;
1919
use FOS\ElasticaBundle\Event\TypeResetEvent;
2020
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
2122

2223
/**
2324
* Deletes and recreates indexes.
@@ -67,6 +68,11 @@ public function __construct(
6768
$this->aliasProcessor = $aliasProcessor;
6869
$this->configManager = $configManager;
6970
$this->dispatcher = $eventDispatcher;
71+
72+
if (class_exists(LegacyEventDispatcherProxy::class)) {
73+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
74+
}
75+
7076
$this->indexManager = $indexManager;
7177
$this->mappingBuilder = $mappingBuilder;
7278
}

src/Persister/InPlacePagerPersister.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use FOS\ElasticaBundle\Persister\Event\PrePersistEvent;
1212
use FOS\ElasticaBundle\Provider\PagerInterface;
1313
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
14+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1415

1516
final class InPlacePagerPersister implements PagerPersisterInterface
1617
{
@@ -34,6 +35,10 @@ public function __construct(PersisterRegistry $registry, EventDispatcherInterfac
3435
{
3536
$this->registry = $registry;
3637
$this->dispatcher = $dispatcher;
38+
39+
if (class_exists(LegacyEventDispatcherProxy::class)) {
40+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
41+
}
3742
}
3843

3944
/**

src/Transformer/ModelToElasticaAutoTransformer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Elastica\Document;
1515
use FOS\ElasticaBundle\Event\TransformEvent;
1616
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17+
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1718
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1819

1920
/**
@@ -55,6 +56,10 @@ public function __construct(array $options = [], EventDispatcherInterface $dispa
5556
{
5657
$this->options = array_merge($this->options, $options);
5758
$this->dispatcher = $dispatcher;
59+
60+
if (class_exists(LegacyEventDispatcherProxy::class)) {
61+
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
62+
}
5863
}
5964

6065
/**

0 commit comments

Comments
 (0)