-
Notifications
You must be signed in to change notification settings - Fork 3
/
RebuildAllIndexesTask.php
50 lines (43 loc) · 1.09 KB
/
RebuildAllIndexesTask.php
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
<?php
namespace BimTheBam\Meilisearch\Dev\Task;
use BimTheBam\Meilisearch\Index;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask;
use Throwable;
/**
* Class RebuildAllIndexesTask
* @package BimTheBam\Meilisearch\Dev\Task
*/
class RebuildAllIndexesTask extends BuildTask
{
/**
* @var string
*/
private static string $segment = 'meilisearch-rebuild-all-indexes';
/**
* @var string
*/
protected $title = 'Rebuild all meilisearch indexes';
/**
* @var string
*/
protected $description = '';
/**
* @param $request
* @return void
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws Throwable
*/
public function run($request): void
{
foreach (ClassInfo::subclassesFor(Index::class, false) as $indexClass) {
/** @var Index $index */
$index = Injector::inst()->create($indexClass);
$index->rebuild();
}
}
}