SwagTestSkipRebuildSubscriber   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A preDeactivate() 0 8 2
A getSubscribedEvents() 0 7 1
A postActivate() 0 8 2
A postDeactivate() 0 8 2
A preActivate() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace SwagTestSkipRebuild;
4
5
use Shopware\Core\Framework\Plugin\Event\PluginPostActivateEvent;
6
use Shopware\Core\Framework\Plugin\Event\PluginPostDeactivateEvent;
7
use Shopware\Core\Framework\Plugin\Event\PluginPreActivateEvent;
8
use Shopware\Core\Framework\Plugin\Event\PluginPreDeactivateEvent;
9
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
10
11
/**
12
 * @internal
13
 */
14
class SwagTestSkipRebuildSubscriber implements EventSubscriberInterface
15
{
16
    public static function getSubscribedEvents(): array
17
    {
18
        return [
19
            PluginPreActivateEvent::class => 'preActivate',
20
            PluginPostActivateEvent::class => 'postActivate',
21
            PluginPreDeactivateEvent::class => 'preDeactivate',
22
            PluginPostDeactivateEvent::class => 'postDeactivate',
23
        ];
24
    }
25
26
    public function preActivate(PluginPreActivateEvent $event): void
27
    {
28
        $plugin = $event->getContext()->getPlugin();
29
        if (!($plugin instanceof SwagTestSkipRebuild)) {
30
            return;
31
        }
32
33
        $plugin->preActivateContext = $event->getContext();
34
    }
35
36
    public function postActivate(PluginPostActivateEvent $event): void
37
    {
38
        $plugin = $event->getContext()->getPlugin();
39
        if (!($plugin instanceof SwagTestSkipRebuild)) {
40
            return;
41
        }
42
43
        $plugin->postActivateContext = $event->getContext();
44
    }
45
46
    public function preDeactivate(PluginPreDeactivateEvent $event): void
47
    {
48
        $plugin = $event->getContext()->getPlugin();
49
        if (!($plugin instanceof SwagTestSkipRebuild)) {
50
            return;
51
        }
52
53
        $plugin->preDeactivateContext = $event->getContext();
54
    }
55
56
    public function postDeactivate(PluginPostDeactivateEvent $event): void
57
    {
58
        $plugin = $event->getContext()->getPlugin();
59
        if (!($plugin instanceof SwagTestSkipRebuild)) {
60
            return;
61
        }
62
63
        $plugin->postDeactivateContext = $event->getContext();
64
    }
65
}
66