Passed
Push — trunk ( ad06ea...8f56e6 )
by Christian
23:45 queued 17s
created

FlowIndexerSubscriber::refreshPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Content\Flow\Indexing;
4
5
use Shopware\Core\Framework\App\Event\AppActivatedEvent;
6
use Shopware\Core\Framework\App\Event\AppDeactivatedEvent;
7
use Shopware\Core\Framework\App\Event\AppDeletedEvent;
8
use Shopware\Core\Framework\App\Event\AppInstalledEvent;
9
use Shopware\Core\Framework\App\Event\AppUpdatedEvent;
10
use Shopware\Core\Framework\DataAbstractionLayer\Indexing\MessageQueue\IterateEntityIndexerMessage;
11
use Shopware\Core\Framework\Log\Package;
12
use Shopware\Core\Framework\Plugin\Event\PluginPostActivateEvent;
13
use Shopware\Core\Framework\Plugin\Event\PluginPostDeactivateEvent;
14
use Shopware\Core\Framework\Plugin\Event\PluginPostInstallEvent;
15
use Shopware\Core\Framework\Plugin\Event\PluginPostUninstallEvent;
16
use Shopware\Core\Framework\Plugin\Event\PluginPostUpdateEvent;
17
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18
use Symfony\Component\Messenger\MessageBusInterface;
19
20
/**
21
 * @internal
22
 */
23
#[Package('business-ops')]
24
class FlowIndexerSubscriber implements EventSubscriberInterface
25
{
26
    public function __construct(private readonly MessageBusInterface $messageBus)
27
    {
28
    }
29
30
    public static function getSubscribedEvents(): array
31
    {
32
        return [
33
            PluginPostInstallEvent::class => 'refreshPlugin',
34
            PluginPostActivateEvent::class => 'refreshPlugin',
35
            PluginPostUpdateEvent::class => 'refreshPlugin',
36
            PluginPostDeactivateEvent::class => 'refreshPlugin',
37
            PluginPostUninstallEvent::class => 'refreshPlugin',
38
            AppInstalledEvent::class => 'refreshPlugin',
39
            AppUpdatedEvent::class => 'refreshPlugin',
40
            AppActivatedEvent::class => 'refreshPlugin',
41
            AppDeletedEvent::class => 'refreshPlugin',
42
            AppDeactivatedEvent::class => 'refreshPlugin',
43
        ];
44
    }
45
46
    public function refreshPlugin(): void
47
    {
48
        // Schedule indexer to update flows
49
        $this->messageBus->dispatch(new IterateEntityIndexerMessage(FlowIndexer::NAME, null));
50
    }
51
}
52