-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExportToElastic.php
More file actions
73 lines (56 loc) · 1.61 KB
/
ExportToElastic.php
File metadata and controls
73 lines (56 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php declare(strict_types = 1);
namespace App\ProductModule\Command;
class ExportToElastic extends \Symfony\Component\Console\Command\Command
{
/**
* @var \App\ProductModule\Model\ExportToElastic
*/
private $exportToElastic;
/**
* @var \Spameri\Elastic\Model\Indices\Delete
*/
private $delete;
/**
* @var \App\ProductModule\Entity\WorkshopProductConfig
*/
private $workshopProductConfig;
/**
* @var \Spameri\Elastic\Model\Indices\Create
*/
private $create;
public function __construct(
\App\ProductModule\Model\ExportToElastic $exportToElastic
, \Spameri\Elastic\Model\Indices\Delete $delete
, \Spameri\Elastic\Model\Indices\Create $create
, \App\ProductModule\Entity\WorkshopProductConfig $workshopProductConfig
)
{
parent::__construct(NULL);
$this->exportToElastic = $exportToElastic;
$this->delete = $delete;
$this->create = $create;
$this->workshopProductConfig = $workshopProductConfig;
}
public function configure(): void
{
$this->setName('exportToElastic');
}
public function execute(
\Symfony\Component\Console\Input\InputInterface $input,
\Symfony\Component\Console\Output\OutputInterface $output
)
{
$options = new \Spameri\Elastic\Import\Run\Options(600);
// Clear index
try {
$this->delete->execute($this->workshopProductConfig->provide()->indexName());
} catch (\Spameri\Elastic\Exception\ElasticSearchException $exception) {}
// Create index
$this->create->execute(
$this->workshopProductConfig->provide()->indexName(),
$this->workshopProductConfig->provide()->toArray()
);
// Export
$this->exportToElastic->execute($options);
}
}