Passed
Push — 6.4 ( be76f2...e19c4d )
by Christian
14:08 queued 13s
created

RefreshIndexSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handled() 0 7 1
A getSubscribedEvents() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\Admin\Subscriber;
4
5
use Shopware\Core\Framework\DataAbstractionLayer\Event\RefreshIndexEvent;
6
use Shopware\Core\Framework\Log\Package;
7
use Shopware\Elasticsearch\Admin\AdminIndexingBehavior;
8
use Shopware\Elasticsearch\Admin\AdminSearchRegistry;
9
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10
11
/**
12
 * @internal
13
 */
14
#[Package('system-settings')]
15
final class RefreshIndexSubscriber implements EventSubscriberInterface
16
{
17
    private AdminSearchRegistry $registry;
18
19
    public function __construct(AdminSearchRegistry $registry)
20
    {
21
        $this->registry = $registry;
22
    }
23
24
    /**
25
     * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, string|arr...y{0: string, 1?: int}>> at position 17 could not be parsed: Expected '>' at position 17, but found 'list'.
Loading history...
26
     */
27
    public static function getSubscribedEvents()
28
    {
29
        return [
30
            RefreshIndexEvent::class => 'handled',
31
        ];
32
    }
33
34
    public function handled(RefreshIndexEvent $event): void
35
    {
36
        $this->registry->iterate(
37
            new AdminIndexingBehavior(
38
                $event->getNoQueue(),
39
                $event->getSkipEntities(),
40
                $event->getOnlyEntities()
41
            )
42
        );
43
    }
44
}
45