Skip to content

Commit 41a1adf

Browse files
makasimsaimaz
authored andcommitted
Symfony 4 support. BC compatible (#853)
* PHP7.2 compatibility. BC compatible. * fix cs * set unlimited memory_limit * add memory limit before composer. * debug * fix * fix tests on sf2 * travis. remove php -i * Add Symfony4 support. BC compatible. * fix typo. * fix ES endpoint in tests. * remove 3.5, 3.6 symfony from travis matrix. * use yaml extension for sf4 config. * trigger travis * trigger travis. * fix tests. * fix tests. * fix cs
1 parent 4220413 commit 41a1adf

18 files changed

+110
-53
lines changed

Command/CacheClearCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
class CacheClearCommand extends AbstractManagerAwareCommand
2222
{
23+
public static $defaultName = 'ongr:es:cache:clear';
24+
2325
/**
2426
* {@inheritdoc}
2527
*/
@@ -28,7 +30,7 @@ protected function configure()
2830
parent::configure();
2931

3032
$this
31-
->setName('ongr:es:cache:clear')
33+
->setName(static::$defaultName)
3234
->setDescription('Clears elasticsearch client cache.');
3335
}
3436

Command/DocumentGenerateCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
class DocumentGenerateCommand extends AbstractManagerAwareCommand
2424
{
25+
public static $defaultName = 'ongr:es:document:generate';
26+
2527
/**
2628
* @var QuestionHelper
2729
*/
@@ -45,7 +47,7 @@ protected function configure()
4547
parent::configure();
4648

4749
$this
48-
->setName('ongr:es:document:generate')
50+
->setName(static::$defaultName)
4951
->setDescription('Generates a new Elasticsearch document inside a bundle');
5052
}
5153

Command/IndexCreateCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
class IndexCreateCommand extends AbstractManagerAwareCommand
2424
{
25+
public static $defaultName = 'ongr:es:index:create';
26+
2527
/**
2628
* {@inheritdoc}
2729
*/
@@ -30,7 +32,7 @@ protected function configure()
3032
parent::configure();
3133

3234
$this
33-
->setName('ongr:es:index:create')
35+
->setName(static::$defaultName)
3436
->setDescription('Creates elasticsearch index.')
3537
->addOption('time', 't', InputOption::VALUE_NONE, 'Adds date suffix to the new index name')
3638
->addOption(

Command/IndexDropCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222
class IndexDropCommand extends AbstractManagerAwareCommand
2323
{
24+
public static $defaultName = 'ongr:es:index:drop';
25+
26+
2427
/**
2528
* {@inheritdoc}
2629
*/
@@ -29,7 +32,7 @@ protected function configure()
2932
parent::configure();
3033

3134
$this
32-
->setName('ongr:es:index:drop')
35+
->setName(static::$defaultName)
3336
->setDescription('Drops elasticsearch index.')
3437
->addOption(
3538
'force',

Command/IndexExportCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class IndexExportCommand extends AbstractManagerAwareCommand
2525
{
26+
public static $defaultName = 'ongr:es:index:export';
27+
2628
/**
2729
* {@inheritdoc}
2830
*/
@@ -31,7 +33,7 @@ protected function configure()
3133
parent::configure();
3234

3335
$this
34-
->setName('ongr:es:index:export')
36+
->setName(static::$defaultName)
3537
->setDescription('Exports data from elasticsearch index.')
3638
->addArgument(
3739
'filename',

Command/IndexImportCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class IndexImportCommand extends AbstractManagerAwareCommand
2525
{
26+
public static $defaultName = 'ongr:es:index:import';
27+
2628
/**
2729
* {@inheritdoc}
2830
*/
@@ -31,7 +33,7 @@ protected function configure()
3133
parent::configure();
3234

3335
$this
34-
->setName('ongr:es:index:import')
36+
->setName(static::$defaultName)
3537
->setDescription('Imports data to elasticsearch index.')
3638
->addArgument(
3739
'filename',

DependencyInjection/Compiler/MappingPass.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\Reference;
18+
use Symfony\Component\HttpKernel\Kernel;
1819

1920
/**
2021
* Compiles elastic search data.
@@ -44,6 +45,7 @@ public function process(ContainerBuilder $container)
4445
$manager,
4546
]
4647
);
48+
$managerDefinition->setPublic(true);
4749
$managerDefinition->setFactory(
4850
[
4951
new Reference('es.manager_factory'),
@@ -56,6 +58,12 @@ public function process(ContainerBuilder $container)
5658
// Make es.manager.default as es.manager service.
5759
if ($managerName === 'default') {
5860
$container->setAlias('es.manager', 'es.manager.default');
61+
62+
if (Kernel::MAJOR_VERSION >= 4) {
63+
$container->getAlias('es.manager')
64+
->setPublic(true)
65+
;
66+
}
5967
}
6068

6169
$mappings = $collector->getMappings($manager['mappings']);
@@ -66,6 +74,7 @@ public function process(ContainerBuilder $container)
6674
'ONGR\ElasticsearchBundle\Service\Repository',
6775
[$repositoryDetails['namespace']]
6876
);
77+
$repositoryDefinition->setPublic(true);
6978

7079
if (isset($repositoryDetails['directory_name']) && $managerName == 'default') {
7180
$container->get('es.document_finder')->setDocumentDir($repositoryDetails['directory_name']);

DependencyInjection/ONGRElasticsearchExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function load(array $configs, ContainerBuilder $container)
6464
new Reference('debug.stopwatch', ContainerInterface::NULL_ON_INVALID_REFERENCE)
6565
]
6666
);
67+
$definition->setPublic(true);
6768
$container->setDefinition('es.manager_factory', $definition);
6869
}
6970
}

Resources/config/services.yml

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,81 @@ parameters:
33

44
services:
55
es.export:
6-
class: ONGR\ElasticsearchBundle\Service\ExportService
6+
class: 'ONGR\ElasticsearchBundle\Service\ExportService'
7+
public: true
78

89
es.import:
9-
class: ONGR\ElasticsearchBundle\Service\ImportService
10+
class: 'ONGR\ElasticsearchBundle\Service\ImportService'
11+
public: true
1012

1113
es.client.index_suffix_finder:
12-
class: ONGR\ElasticsearchBundle\Service\IndexSuffixFinder
14+
class: 'ONGR\ElasticsearchBundle\Service\IndexSuffixFinder'
15+
public: true
1316

1417
es.cache_engine:
15-
class: Doctrine\Common\Cache\FilesystemCache
18+
class: 'Doctrine\Common\Cache\FilesystemCache'
19+
public: true
1620
arguments: ["%kernel.cache_dir%/ongr/elasticsearch", ".ongr.data"]
1721

1822
es.annotations.cached_reader:
19-
class: Doctrine\Common\Annotations\CachedReader
23+
class: 'Doctrine\Common\Annotations\CachedReader'
24+
public: true
2025
arguments: ["@annotations.reader", "@es.cache_engine", "%kernel.debug%"]
2126

2227
es.document_finder:
23-
class: ONGR\ElasticsearchBundle\Mapping\DocumentFinder
28+
class: 'ONGR\ElasticsearchBundle\Mapping\DocumentFinder'
29+
public: true
2430
arguments: ["%kernel.bundles%"]
25-
public: false
2631

2732
es.document_parser:
28-
class: ONGR\ElasticsearchBundle\Mapping\DocumentParser
33+
class: 'ONGR\ElasticsearchBundle\Mapping\DocumentParser'
34+
public: true
2935
arguments: ["@es.annotations.cached_reader", "@es.document_finder"]
30-
public: false
3136

3237
es.metadata_collector:
33-
class: ONGR\ElasticsearchBundle\Mapping\MetadataCollector
38+
class: 'ONGR\ElasticsearchBundle\Mapping\MetadataCollector'
39+
public: true
3440
arguments: ["@es.document_finder", "@es.document_parser", "@es.cache_engine"]
3541
calls:
3642
- [setEnableCache, ["%es.cache%"]]
3743

3844
es.logger.collection_handler:
39-
class: ONGR\ElasticsearchBundle\Profiler\Handler\CollectionHandler
45+
class: 'ONGR\ElasticsearchBundle\Profiler\Handler\CollectionHandler'
4046
public: false
4147

4248
es.tracer:
43-
class: Monolog\Logger
49+
class: 'Monolog\Logger'
50+
public: true
4451
arguments: ['ongr']
4552
calls:
46-
- [pushHandler, ["@es.logger.collection_handler"]]
53+
- ['pushHandler', ["@es.logger.collection_handler"]]
4754

4855
es.profiler:
49-
class: ONGR\ElasticsearchBundle\Profiler\ElasticsearchProfiler
56+
class: 'ONGR\ElasticsearchBundle\Profiler\ElasticsearchProfiler'
57+
public: true
5058
calls:
51-
- [setManagers, ["%es.managers%"]]
52-
- [addLogger, ["@es.tracer"]]
59+
- ['setManagers', ["%es.managers%"]]
60+
- ['addLogger', ["@es.tracer"]]
5361
tags:
54-
- {name: data_collector, template: "@ONGRElasticsearch/Profiler/profiler.html.twig", id: ongr.profiler}
62+
- { name: 'data_collector', template: "@ONGRElasticsearch/Profiler/profiler.html.twig", id: 'ongr.profiler' }
5563

5664
es.result_converter:
57-
class: ONGR\ElasticsearchBundle\Result\Converter
65+
class: 'ONGR\ElasticsearchBundle\Result\Converter'
66+
public: true
5867
arguments: ["@es.metadata_collector"]
5968

6069
es.terminate_listener:
61-
class: ONGR\ElasticsearchBundle\EventListener\TerminateListener
70+
class: 'ONGR\ElasticsearchBundle\EventListener\TerminateListener'
71+
public: true
6272
arguments: ["@service_container", "%es.managers%"]
6373
tags:
64-
- { name: kernel.event_listener, event: kernel.terminate }
74+
- { name: 'kernel.event_listener', event: 'kernel.terminate' }
6575

6676
es.generator.document:
67-
class: ONGR\ElasticsearchBundle\Generator\DocumentGenerator
77+
class: 'ONGR\ElasticsearchBundle\Generator\DocumentGenerator'
78+
public: true
6879

6980
es.generate:
70-
class: ONGR\ElasticsearchBundle\Service\GenerateService
81+
class: 'ONGR\ElasticsearchBundle\Service\GenerateService'
82+
public: true
7183
arguments: ["@es.generator.document", "@filesystem"]

Resources/config/services4.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
services:
22
ONGR\ElasticsearchBundle\Command\:
33
resource: '../../Command'
4+
public: true
45
tags:
56
- { name: console.command }

0 commit comments

Comments
 (0)