-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathImportCoursesToElasticsearchCommand.php
More file actions
34 lines (27 loc) · 969 Bytes
/
ImportCoursesToElasticsearchCommand.php
File metadata and controls
34 lines (27 loc) · 969 Bytes
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
<?php
declare(strict_types=1);
namespace CodelyTv\Apps\Backoffice\Frontend\Command;
use CodelyTv\Backoffice\Courses\Infrastructure\Persistence\ElasticsearchBackofficeCourseRepository;
use CodelyTv\Backoffice\Courses\Infrastructure\Persistence\MySqlBackofficeCourseRepository;
use Override;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class ImportCoursesToElasticsearchCommand extends Command
{
public function __construct(
private readonly MySqlBackofficeCourseRepository $mySqlRepository,
private readonly ElasticsearchBackofficeCourseRepository $elasticRepository
) {
parent::__construct();
}
#[Override]
public function execute(InputInterface $input, OutputInterface $output): int
{
$courses = $this->mySqlRepository->searchAll();
foreach ($courses as $course) {
$this->elasticRepository->save($course);
}
return 0;
}
}