Skip to content

Commit 6e9b892

Browse files
committed
removed event system
- removed event system from phrase provider, will be re-added with #49520
1 parent f2e28b1 commit 6e9b892

File tree

11 files changed

+3
-166
lines changed

11 files changed

+3
-166
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/translation_providers.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
service('logger'),
7272
service('translation.loader.xliff'),
7373
service('translation.dumper.xliff'),
74-
service('event_dispatcher'),
7574
service('cache.app'),
7675
param('kernel.default_locale'),
7776
])

src/Symfony/Component/Translation/Bridge/Phrase/Event/AbstractPhraseEvent.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Symfony/Component/Translation/Bridge/Phrase/Event/PhraseReadEvent.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Symfony/Component/Translation/Bridge/Phrase/Event/PhraseWriteEvent.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Symfony/Component/Translation/Bridge/Phrase/PhraseProvider.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313

1414
use Psr\Cache\CacheItemInterface;
1515
use Psr\Cache\CacheItemPoolInterface;
16-
use Psr\EventDispatcher\EventDispatcherInterface;
1716
use Psr\Log\LoggerInterface;
1817
use Symfony\Component\Mime\Part\DataPart;
1918
use Symfony\Component\Mime\Part\Multipart\FormDataPart;
2019
use Symfony\Component\Translation\Bridge\Phrase\Cache\PhraseCachedResponse;
2120
use Symfony\Component\Translation\Bridge\Phrase\Config\ReadConfig;
2221
use Symfony\Component\Translation\Bridge\Phrase\Config\WriteConfig;
23-
use Symfony\Component\Translation\Bridge\Phrase\Event\PhraseReadEvent;
24-
use Symfony\Component\Translation\Bridge\Phrase\Event\PhraseWriteEvent;
2522
use Symfony\Component\Translation\Dumper\XliffFileDumper;
2623
use Symfony\Component\Translation\Exception\ProviderException;
2724
use Symfony\Component\Translation\Loader\LoaderInterface;
@@ -43,7 +40,6 @@ public function __construct(
4340
private readonly LoggerInterface $logger,
4441
private readonly LoaderInterface $loader,
4542
private readonly XliffFileDumper $xliffFileDumper,
46-
private readonly EventDispatcherInterface $dispatcher,
4743
private readonly CacheItemPoolInterface $cache,
4844
private readonly string $defaultLocale,
4945
private readonly string $endpoint,
@@ -99,22 +95,14 @@ public function read(array $domains, array $locales): TranslatorBag
9995
}
10096
}
10197

102-
$event = new PhraseReadEvent($translatorBag);
103-
$this->dispatcher->dispatch($event);
104-
105-
return $event->getBag();
98+
return $translatorBag;
10699
}
107100

108101
public function write(TranslatorBagInterface $translatorBag): void
109102
{
110103
\assert($translatorBag instanceof TranslatorBag);
111104

112-
$event = new PhraseWriteEvent($translatorBag);
113-
$this->dispatcher->dispatch($event);
114-
115-
$catalogues = $event->getBag()->getCatalogues();
116-
117-
foreach ($catalogues as $catalogue) {
105+
foreach ($translatorBag->getCatalogues() as $catalogue) {
118106
foreach ($catalogue->getDomains() as $domain) {
119107
if (0 === \count($catalogue->all($domain))) {
120108
continue;

src/Symfony/Component/Translation/Bridge/Phrase/PhraseProviderFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Translation\Bridge\Phrase;
1313

1414
use Psr\Cache\CacheItemPoolInterface;
15-
use Psr\EventDispatcher\EventDispatcherInterface;
1615
use Psr\Log\LoggerInterface;
1716
use Symfony\Component\Translation\Bridge\Phrase\Config\ReadConfig;
1817
use Symfony\Component\Translation\Bridge\Phrase\Config\WriteConfig;
@@ -36,7 +35,6 @@ public function __construct(
3635
private readonly LoggerInterface $logger,
3736
private readonly LoaderInterface $loader,
3837
private readonly XliffFileDumper $xliffFileDumper,
39-
private readonly EventDispatcherInterface $dispatcher,
4038
private readonly CacheItemPoolInterface $cache,
4139
private readonly string $defaultLocale,
4240
) {
@@ -65,7 +63,7 @@ public function create(Dsn $dsn): ProviderInterface
6563
$readConfig = ReadConfig::fromDsn($dsn);
6664
$writeConfig = WriteConfig::fromDsn($dsn);
6765

68-
return new PhraseProvider($client, $this->logger, $this->loader, $this->xliffFileDumper, $this->dispatcher, $this->cache, $this->defaultLocale, $endpoint, $readConfig, $writeConfig);
66+
return new PhraseProvider($client, $this->logger, $this->loader, $this->xliffFileDumper, $this->cache, $this->defaultLocale, $endpoint, $readConfig, $writeConfig);
6967
}
7068

7169
protected function getSupportedSchemes(): array

src/Symfony/Component/Translation/Bridge/Phrase/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,6 @@ Cache
4747
The read responses from Phrase are cached to speed up the read and delete method of this provider and also to contribute to the rate limit as little as possible.
4848
Therefor the factory should be initialised with a PSR-6 compatible cache adapter.
4949

50-
Events
51-
------
52-
53-
To enable you to perform post-processing on translation values and / or keys, two events are dispatched by this provider class.
54-
55-
**PhraseReadEvent**
56-
57-
_After_ reading the catalogue from Phrase, the resulting `TranslatorBag` is dispatched in a `PhraseReadEvent` prior to being returned from the read method.
58-
59-
**PhraseWriteEvent**
60-
61-
_Before_ writing the catalogue to Phrase, the `TranslatorBag` is dispatched in a `PhraseWriteEvent`.
62-
6350
Fine tuning your Phrase api calls
6451
---------------------------------
6552

src/Symfony/Component/Translation/Bridge/Phrase/Tests/Event/PhraseEventTest.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Symfony/Component/Translation/Bridge/Phrase/Tests/PhraseProviderFactoryTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
1616
use Psr\Cache\CacheItemPoolInterface;
17-
use Psr\EventDispatcher\EventDispatcherInterface;
1817
use Psr\Log\LoggerInterface;
1918
use Symfony\Component\HttpClient\MockHttpClient;
2019
use Symfony\Component\Translation\Bridge\Phrase\PhraseProviderFactory;
@@ -34,7 +33,6 @@ class PhraseProviderFactoryTest extends TestCase
3433
private MockObject&LoggerInterface $logger;
3534
private MockObject&LoaderInterface $loader;
3635
private MockObject&XliffFileDumper $xliffFileDumper;
37-
private MockObject&EventDispatcherInterface $dispatcher;
3836
private MockObject&CacheItemPoolInterface $cache;
3937
private string $defaultLocale;
4038

@@ -153,7 +151,6 @@ private function createFactory(): PhraseProviderFactory
153151
$this->getLogger(),
154152
$this->getLoader(),
155153
$this->getXliffFileDumper(),
156-
$this->getDispatcher(),
157154
$this->getCache(),
158155
$this->getDefaultLocale()
159156
);
@@ -179,11 +176,6 @@ private function getXliffFileDumper(): XliffFileDumper&MockObject
179176
return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class);
180177
}
181178

182-
private function getDispatcher(): MockObject&EventDispatcherInterface
183-
{
184-
return $this->dispatcher ??= $this->createMock(EventDispatcherInterface::class);
185-
}
186-
187179
private function getCache(): MockObject&CacheItemPoolInterface
188180
{
189181
return $this->cache ??= $this->createMock(CacheItemPoolInterface::class);

src/Symfony/Component/Translation/Bridge/Phrase/Tests/PhraseProviderTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\TestCase;
1616
use Psr\Cache\CacheItemInterface;
1717
use Psr\Cache\CacheItemPoolInterface;
18-
use Psr\EventDispatcher\EventDispatcherInterface;
1918
use Psr\Log\LoggerInterface;
2019
use Symfony\Component\HttpClient\HttpClientTrait;
2120
use Symfony\Component\HttpClient\MockHttpClient;
@@ -48,7 +47,6 @@ class PhraseProviderTest extends TestCase
4847
private MockObject&LoggerInterface $logger;
4948
private MockObject&LoaderInterface $loader;
5049
private MockObject&XliffFileDumper $xliffFileDumper;
51-
private MockObject&EventDispatcherInterface $dispatcher;
5250
private MockObject&CacheItemPoolInterface $cache;
5351
private string $defaultLocale;
5452
private string $endpoint;
@@ -104,11 +102,6 @@ public function testRead(string $locale, string $localeId, string $domain, strin
104102
->method('load')
105103
->willReturn($expectedTranslatorBag->getCatalogue($locale));
106104

107-
$this->getDispatcher()
108-
->expects(self::once())
109-
->method('dispatch')
110-
->with(self::isInstanceOf(PhraseReadEvent::class));
111-
112105
$provider = $this->createProvider(httpClient: (new MockHttpClient($responses))->withOptions([
113106
'base_uri' => 'https://api.phrase.com/api/v2/projects/1/',
114107
'headers' => [
@@ -179,11 +172,6 @@ public function testReadCached(string $locale, string $localeId, string $domain,
179172
->method('load')
180173
->willReturn($expectedTranslatorBag->getCatalogue($locale));
181174

182-
$this->getDispatcher()
183-
->expects(self::once())
184-
->method('dispatch')
185-
->with(self::isInstanceOf(PhraseReadEvent::class));
186-
187175
$provider = $this->createProvider(httpClient: (new MockHttpClient($responses))->withOptions([
188176
'base_uri' => 'https://api.phrase.com/api/v2/projects/1/',
189177
'headers' => [
@@ -792,11 +780,6 @@ public function testWrite(string $locale, string $localeId, string $domain, stri
792780
},
793781
];
794782

795-
$this->getDispatcher()
796-
->expects(self::once())
797-
->method('dispatch')
798-
->with(self::isInstanceOf(PhraseWriteEvent::class));
799-
800783
$provider = $this->createProvider(httpClient: (new MockHttpClient($responses))->withOptions([
801784
'base_uri' => 'https://api.phrase.com/api/v2/projects/1/',
802785
'headers' => [
@@ -1194,7 +1177,6 @@ private function createProvider(MockHttpClient $httpClient = null, string $endpo
11941177
$this->getLogger(),
11951178
$this->getLoader(),
11961179
$dumper ?? $this->getXliffFileDumper(),
1197-
$this->getDispatcher(),
11981180
$this->getCache(),
11991181
$this->getDefaultLocale(),
12001182
$endpoint ?? $this->getEndpoint(),
@@ -1223,11 +1205,6 @@ private function getXliffFileDumper(): XliffFileDumper&MockObject
12231205
return $this->xliffFileDumper ??= $this->createMock(XliffFileDumper::class);
12241206
}
12251207

1226-
private function getDispatcher(): MockObject&EventDispatcherInterface
1227-
{
1228-
return $this->dispatcher ??= $this->createMock(EventDispatcherInterface::class);
1229-
}
1230-
12311208
private function getCache(): MockObject&CacheItemPoolInterface
12321209
{
12331210
return $this->cache ??= $this->createMock(CacheItemPoolInterface::class);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy