Skip to content

Commit 3eadae2

Browse files
authored
Merge pull request #230 from delyriand/feature/add-context-in-event
feat: add context in event for more flexibility
2 parents 80a8359 + 193ec68 commit 3eadae2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Event/MappingProviderEvent.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ class MappingProviderEvent extends Event
2727
*/
2828
private ?ArrayObject $mapping;
2929

30+
private array $context;
31+
3032
/**
3133
* @param ArrayObject<string, array>|null $mapping
3234
*/
33-
public function __construct(string $indexCode, ?ArrayObject $mapping)
35+
public function __construct(string $indexCode, ?ArrayObject $mapping, array $context = [])
3436
{
3537
$this->indexCode = $indexCode;
3638
$this->mapping = $mapping;
39+
$this->context = $context;
3740
}
3841

3942
public function getIndexCode(): string
@@ -48,4 +51,9 @@ public function getMapping(): ?ArrayObject
4851
{
4952
return $this->mapping;
5053
}
54+
55+
public function getContext(): array
56+
{
57+
return $this->context;
58+
}
5159
}

src/Mapping/YamlWithLocaleProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function provideMapping(string $indexName, array $context = []): ?array
6060
$mapping = $this->appendLocaleAnalyzers($configurationDirectory, $mapping, $locale);
6161
}
6262

63-
$mappingProviderEvent = new MappingProviderEvent($context['index_code'] ?? $indexName, new ArrayObject($mapping));
63+
$mappingProviderEvent = new MappingProviderEvent($context['index_code'] ?? $indexName, new ArrayObject($mapping), $context);
6464
$this->eventDispatcher->dispatch(
6565
$mappingProviderEvent,
6666
MappingProviderEvent::EVENT_NAME

0 commit comments

Comments
 (0)