Skip to content

Commit a2eabad

Browse files
authored
Merge pull request #887 from einorler/alias
implemented overriding alias name for document
2 parents 52b67a8 + d5ccc0e commit a2eabad

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ install:
1616
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
1717
before_script:
1818
- composer require --no-update symfony/framework-bundle:${SYMFONY}
19-
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
19+
- if [[ $TRAVIS_SECURE_ENV_VARS = "true" ]]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
2020
- composer install --no-interaction --prefer-dist
2121
script:
2222
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
2323
- vendor/bin/phpunit --coverage-clover=coverage.clover
2424
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/cache ./
2525
after_script:
26-
- travis_retry php vendor/bin/coveralls
26+
- travis_retry php vendor/bin/coveralls

DependencyInjection/Compiler/MappingPass.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@ private function handleDirectoryMapping(ContainerBuilder $container, string $dir
6262

6363
foreach ($this->getNamespaces($dir) as $namespace) {
6464
$class = new \ReflectionClass($namespace);
65+
66+
if (isset($indexesOverride[$namespace]['alias']) && $indexesOverride[$namespace]['alias']) {
67+
$indexAlias = $indexesOverride[$namespace]['alias'];
68+
} else {
69+
$indexAlias = $parser->getIndexAliasName($class);
70+
}
71+
6572
/** @var Index $document */
6673
$document = $parser->getIndexAnnotation($class);
6774
$indexMapping = $parser->getIndexMetadata($class);
68-
$indexAlias = $parser->getIndexAliasName($class);
6975
$indexMetadata = $parser->getIndexMetadata($class);
7076

7177
if (!empty($indexMapping)) {

Tests/Functional/Service/IndexServiceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public function indexNameDataProvider()
4545
{
4646
return [
4747
[ DummyDocument::class, DummyDocument::INDEX_NAME ],
48-
[ DummyDocumentInTheEntityDirectory::class, DummyDocumentInTheEntityDirectory::INDEX_NAME ],
48+
// this alias is overriden in configuration
49+
[ DummyDocumentInTheEntityDirectory::class, 'field-data-index' ],
4950
];
5051
}
5152

0 commit comments

Comments
 (0)