Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/es7_support'
Browse files Browse the repository at this point in the history
  • Loading branch information
saimaz committed Feb 5, 2020
2 parents a27a4d9 + f535901 commit e1a6398
Show file tree
Hide file tree
Showing 57 changed files with 201 additions and 1,026 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Expand Up @@ -4,15 +4,20 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4
env:
global:
- ES_VERSION=6.2.3 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
- ES_VERSION=7.5.2 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
matrix:
- SYMFONY="~3.4"
- SYMFONY="^4.1"
- SYMFONY="^4.4"
- SYMFONY="^5.0"
jobs:
exclude:
- php: 7.1
env: SYMFONY="^5.0"
install:
- wget ${ES_DOWNLOAD_URL}
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
- tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
before_script:
- composer require --no-update symfony/framework-bundle:${SYMFONY}
Expand All @@ -23,4 +28,4 @@ script:
- 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 bash <(curl -s https://codecov.io/bash)
8 changes: 0 additions & 8 deletions Annotation/Index.php
Expand Up @@ -37,14 +37,6 @@ final class Index extends AbstractAnnotation

public $numberOfReplicas = 1;

/**
* We strongly recommend to not use this parameter in the index annotation. By default it will be set as `_doc`
* type name. Eventually it will be removed.
*
* @deprecated will be removed in v7 since there will be no more types in the indexes.
*/
public $typeName = '_doc';

/**
* You can select one of your indexes to be default. Useful for cli commands when you don't
* need to define an alias name. If default is not set the first index found will be set as default one.
Expand Down
27 changes: 21 additions & 6 deletions Command/AbstractIndexServiceAwareCommand.php
Expand Up @@ -14,12 +14,22 @@
use ONGR\ElasticsearchBundle\DependencyInjection\Configuration;
use ONGR\ElasticsearchBundle\Service\IndexService;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\DependencyInjection\Container;

abstract class AbstractIndexServiceAwareCommand extends ContainerAwareCommand
abstract class AbstractIndexServiceAwareCommand extends Command
{
private $container;

const INDEX_OPTION = 'index';

public function __construct(Container $container)
{
$this->container = $container;
parent::__construct();
}

protected function configure()
{
$this->addOption(
Expand All @@ -32,19 +42,24 @@ protected function configure()

protected function getIndex($name): IndexService
{
$name = $name ?? $this->getContainer()->getParameter(Configuration::ONGR_DEFAULT_INDEX);
$indexes = $this->getContainer()->getParameter(Configuration::ONGR_INDEXES);
$name = $name ?? $this->container->getParameter(Configuration::ONGR_DEFAULT_INDEX);
$indexes = $this->container->getParameter(Configuration::ONGR_INDEXES);

if (isset($indexes[$name]) && $this->getContainer()->has($indexes[$name])) {
return $this->getContainer()->get($indexes[$name]);
if (isset($indexes[$name]) && $this->container->has($indexes[$name])) {
return $this->container->get($indexes[$name]);
}

throw new \RuntimeException(
sprintf(
'There is no index under `%s` name found. Available options: `%s`.',
$name,
implode('`, `', array_keys($this->getContainer()->getParameter(Configuration::ONGR_INDEXES)))
implode('`, `', array_keys($this->container->getParameter(Configuration::ONGR_INDEXES)))
)
);
}

public function getContainer(): Container
{
return $this->container;
}
}
2 changes: 2 additions & 0 deletions Command/CacheClearCommand.php
Expand Up @@ -46,5 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$index->getIndexName()
)
);

return 0;
}
}

0 comments on commit e1a6398

Please sign in to comment.