Skip to content

Commit

Permalink
Merge e01edb8 into 26c1125
Browse files Browse the repository at this point in the history
  • Loading branch information
einorler committed Oct 3, 2019
2 parents 26c1125 + e01edb8 commit 43bbe6a
Show file tree
Hide file tree
Showing 41 changed files with 967 additions and 934 deletions.
22 changes: 8 additions & 14 deletions .travis.yml
@@ -1,27 +1,21 @@
sudo: required
language: php
php:
- 7.0
- 7.1
- hhvm
- 7.2
- 7.3
env:
global:
- ES_VERSION="5.0" JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre"
matrix:
allow_failures:
- php: hhvm
- ES_VERSION=6.2.3 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
install:
# Container based PHP image ues PHP 5.6.5, once it will be upgraded sudo will be not necessary
- sudo apt-get install -y oracle-java8-set-default
- ES_URL=$(curl -sS "https://esvm-props.kibana.rocks/builds" | jq -r ".branches[\"$ES_VERSION\"].zip")
- curl -L -o elasticsearch.zip $ES_URL
- unzip elasticsearch.zip
- ./elasticsearch-*/bin/elasticsearch -d
- wget ${ES_DOWNLOAD_URL}
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
before_script:
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH
- composer install --no-interaction --prefer-dist
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction
script:
- vendor/bin/phpunit --coverage-clover=coveralls.clover
- vendor/bin/phpcs -p --standard=PSR2 --extensions=php --ignore=vendor/,Tests/app/ ./
after_script:
- travis_retry php vendor/bin/coveralls
- travis_retry php vendor/bin/coveralls
1 change: 1 addition & 0 deletions DependencyInjection/Compiler/FilterPass.php
Expand Up @@ -83,6 +83,7 @@ public function process(ContainerBuilder $container)
new Reference('jms_serializer')
]
);
$managerDefinition->setPublic(true);

$container->setDefinition(ONGRFilterManagerExtension::getFilterManagerId($managerName), $managerDefinition);
}
Expand Down
40 changes: 19 additions & 21 deletions README.md
Expand Up @@ -29,7 +29,7 @@ FilterManager bundle is installed using [Composer](https://getcomposer.org).

```bash
# You can require any version you need, check the latest stable to make sure you are using the newest version.
$ composer require ongr/filter-manager-bundle "~2.0"
$ composer require ongr/filter-manager-bundle "~3.0"
```

> Please note that filter manager requires Elasticsearch bundle, guide on how to install and configure it can be found [here](https://github.com/ongr-io/ElasticsearchBundle).
Expand All @@ -39,19 +39,19 @@ $ composer require ongr/filter-manager-bundle "~2.0"
Enable Filter Manager bundle in your AppKernel:

```php
// app/AppKernel.php

public function registerBundles()
{
$bundles = [
// ...
new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(),
new ONGR\FilterManagerBundle\ONGRFilterManagerBundle(),
new \JMS\SerializerBundle\JMSSerializerBundle(),
];
// ...
}
// config/bundles.php

<?php

return [
...

ONGR\ElasticsearchBundle\ONGRElasticsearchBundle::class => ['all' => true],
ONGR\FilterManagerBundle\ONGRFilterManagerBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],

...
];
```

### Step 3: Add configuration for manager
Expand All @@ -62,19 +62,17 @@ Add minimal configuration for Elasticsearch and FilterManager bundles.
# app/config/config.yml

ongr_elasticsearch:
managers:
default:
index:
hosts:
- 127.0.0.1:9200
index_name: products
indexes:
App\Document\Product:
hosts:
- 127.0.0.1:9200

ongr_filter_manager:
managers:
search_list: # <- Filter manager name
filters:
- country
repository: es.manager.default.product # <- Product document repository service to execute queries on
repository: App\Document\Product # <- Product document rindex service (used to be a repository prior to v3.0)
filters:
country: # <- Filter name
type: choice
Expand Down
3 changes: 2 additions & 1 deletion Search/FilterManager.php
Expand Up @@ -12,6 +12,7 @@
namespace ONGR\FilterManagerBundle\Search;

use JMS\Serializer\Serializer;
use ONGR\ElasticsearchBundle\Service\IndexService;
use ONGR\ElasticsearchDSL\Search;
use ONGR\ElasticsearchBundle\Service\Repository;
use ONGR\ElasticsearchBundle\Result\DocumentIterator;
Expand Down Expand Up @@ -62,7 +63,7 @@ class FilterManager implements FilterManagerInterface
*/
public function __construct(
FilterContainer $container,
Repository $repository,
IndexService $repository,
EventDispatcherInterface $eventDispatcher,
$serializer
) {
Expand Down
38 changes: 21 additions & 17 deletions Tests/Functional/Controller/ManagerControllerTest.php
Expand Up @@ -11,6 +11,7 @@

namespace ONGR\FilterManagerBundle\Tests\Functional\Controller;

use App\Document\Product;
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;

class ManagerControllerTest extends AbstractElasticsearchTestCase
Expand All @@ -21,23 +22,21 @@ class ManagerControllerTest extends AbstractElasticsearchTestCase
protected function getDataArray()
{
return [
'default' => [
'product' => [
[
'_id' => 1,
'title' => 'Foo product',
'color' => 'red',
],
[
'_id' => 2,
'title' => 'Foo cool product',
'color' => 'red',
],
[
'_id' => 3,
'title' => 'Another cool product',
'color' => 'red',
],
Product::class => [
[
'_id' => 1,
'title' => 'Foo product',
'color' => 'red',
],
[
'_id' => 2,
'title' => 'Foo cool product',
'color' => 'red',
],
[
'_id' => 3,
'title' => 'Another cool product',
'color' => 'red',
],
],
];
Expand Down Expand Up @@ -88,4 +87,9 @@ public function testPrettyJsonAction()

$this->assertTrue(substr_count($response->getContent(), PHP_EOL) > 1);
}

protected function setUp()
{
$this->getIndex(Product::class);
}
}
152 changes: 78 additions & 74 deletions Tests/Functional/DependencyInjection/Compiler/FilterPassTest.php
Expand Up @@ -11,6 +11,7 @@

namespace ONGR\FilterManagerBundle\Tests\Functional\Filter\Widget\Choice;

use App\Document\Product;
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;
use ONGR\FilterManagerBundle\DependencyInjection\ONGRFilterManagerExtension;
use ONGR\FilterManagerBundle\Filter\ViewData\ChoicesAwareViewData;
Expand All @@ -24,80 +25,78 @@ class FilterPassTest extends AbstractElasticsearchTestCase
protected function getDataArray()
{
return [
'default' => [
'product' => [
[
'_id' => 1,
'color' => 'blue',
'active' => true,
'price' => 1.5,
],
[
'_id' => 2,
'color' => 'blue',
'active' => false,
'price' => 2.5,
],
[
'_id' => 3,
'color' => 'blue',
'active' => true,
'price' => 3.5,
],
[
'_id' => 4,
'color' => 'blue',
'active' => false,
'price' => 4.5,
],
[
'_id' => 5,
'color' => 'red',
'active' => true,
'price' => 2.5,
],
[
'_id' => 6,
'color' => 'red',
'active' => false,
'price' => 3.5,
],
[
'_id' => 7,
'color' => 'red',
'active' => true,
'price' => 4.5,
],
[
'_id' => 8,
'color' => 'red',
'active' => false,
'price' => 5.5,
],
[
'_id' => 9,
'color' => 'green',
'active' => true,
'price' => 4.5,
],
[
'_id' => 10,
'color' => 'green',
'active' => false,
'price' => 5.5,
],
[
'_id' => 11,
'color' => 'yellow',
'active' => true,
'price' => 6.5,
],
[
'_id' => 12,
'color' => 'yellow',
'active' => false,
'price' => 7.5,
],
Product::class => [
[
'_id' => 1,
'color' => 'blue',
'active' => true,
'price' => 1.5,
],
[
'_id' => 2,
'color' => 'blue',
'active' => false,
'price' => 2.5,
],
[
'_id' => 3,
'color' => 'blue',
'active' => true,
'price' => 3.5,
],
[
'_id' => 4,
'color' => 'blue',
'active' => false,
'price' => 4.5,
],
[
'_id' => 5,
'color' => 'red',
'active' => true,
'price' => 2.5,
],
[
'_id' => 6,
'color' => 'red',
'active' => false,
'price' => 3.5,
],
[
'_id' => 7,
'color' => 'red',
'active' => true,
'price' => 4.5,
],
[
'_id' => 8,
'color' => 'red',
'active' => false,
'price' => 5.5,
],
[
'_id' => 9,
'color' => 'green',
'active' => true,
'price' => 4.5,
],
[
'_id' => 10,
'color' => 'green',
'active' => false,
'price' => 5.5,
],
[
'_id' => 11,
'color' => 'yellow',
'active' => true,
'price' => 6.5,
],
[
'_id' => 12,
'color' => 'yellow',
'active' => false,
'price' => 7.5,
],
],
];
Expand Down Expand Up @@ -216,4 +215,9 @@ public function testRelations(Request $request, $manager, $filter, array $expect

$this->assertEquals($expectedChoices, $actualChoices);
}

protected function setUp()
{
$this->getIndex(Product::class);
}
}

0 comments on commit 43bbe6a

Please sign in to comment.