Skip to content

Commit

Permalink
Merge pull request #887 from einorler/alias
Browse files Browse the repository at this point in the history
implemented overriding alias name for document
  • Loading branch information
einorler authored Oct 21, 2019
2 parents 52b67a8 + d5ccc0e commit a2eabad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ install:
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
before_script:
- composer require --no-update symfony/framework-bundle:${SYMFONY}
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
- if [[ $TRAVIS_SECURE_ENV_VARS = "true" ]]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
- composer install --no-interaction --prefer-dist
script:
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
- vendor/bin/phpunit --coverage-clover=coverage.clover
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,Tests/app/,var/cache ./
after_script:
- travis_retry php vendor/bin/coveralls
- travis_retry php vendor/bin/coveralls
8 changes: 7 additions & 1 deletion DependencyInjection/Compiler/MappingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ private function handleDirectoryMapping(ContainerBuilder $container, string $dir

foreach ($this->getNamespaces($dir) as $namespace) {
$class = new \ReflectionClass($namespace);

if (isset($indexesOverride[$namespace]['alias']) && $indexesOverride[$namespace]['alias']) {
$indexAlias = $indexesOverride[$namespace]['alias'];
} else {
$indexAlias = $parser->getIndexAliasName($class);
}

/** @var Index $document */
$document = $parser->getIndexAnnotation($class);
$indexMapping = $parser->getIndexMetadata($class);
$indexAlias = $parser->getIndexAliasName($class);
$indexMetadata = $parser->getIndexMetadata($class);

if (!empty($indexMapping)) {
Expand Down
3 changes: 2 additions & 1 deletion Tests/Functional/Service/IndexServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function indexNameDataProvider()
{
return [
[ DummyDocument::class, DummyDocument::INDEX_NAME ],
[ DummyDocumentInTheEntityDirectory::class, DummyDocumentInTheEntityDirectory::INDEX_NAME ],
// this alias is overriden in configuration
[ DummyDocumentInTheEntityDirectory::class, 'field-data-index' ],
];
}

Expand Down

0 comments on commit a2eabad

Please sign in to comment.