PreExecuteEventSubscriber::getSubscribedEvents()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\DoctrineFixtureModule\Listener;
7
8
use Doctrine\Fixture\Event\BulkFixtureEvent;
9
use Doctrine\Fixture\Event\BulkImportFixtureEventListener;
10
use Doctrine\Fixture\Event\BulkPurgeFixtureEventListener;
11
use Nnx\DoctrineFixtureModule\Event\FixtureExecutorEvent;
12
13
/**
14
 * Class PreExecuteEventSubscriber
15
 *
16
 * @package Nnx\DoctrineFixtureModule\Listener
17
 */
18 View Code Duplication
class PreExecuteEventSubscriber
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    extends AbstractExecuteEventSubscriber
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "AbstractExecuteEventSubscriber" and comma; 1 found
Loading history...
20
    implements
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
21
        PreExecuteEventSubscriberInterface,
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces before interface name; 8 found
Loading history...
22
        BulkImportFixtureEventListener,
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces before interface name; 8 found
Loading history...
23
        BulkPurgeFixtureEventListener
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces before interface name; 8 found
Loading history...
24
{
25
26
    /**
27
     * Идендфикатор для менеджера событий
28
     *
29
     * @var array
30
     */
31
    protected $eventIdentifier = [
32
        PreExecuteEventSubscriberInterface::class
33
    ];
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getSubscribedEvents()
39
    {
40
        return [
41
            BulkImportFixtureEventListener::BULK_IMPORT,
42
            BulkPurgeFixtureEventListener::BULK_PURGE,
43
        ];
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     * @throws \Nnx\DoctrineFixtureModule\Executor\Exception\RuntimeException
49
     */
50
    public function bulkImport(BulkFixtureEvent $event)
51
    {
52
        $workflowExecutorEvent = clone $this->getPrototypeEvent();
53
        $workflowExecutorEvent->setName(FixtureExecutorEvent::START_EXECUTE_FIXTURES_EVENT);
54
        $workflowExecutorEvent->setMethod(FixtureExecutorEvent::IMPORT);
55
        $executor = $this->getExecutor();
56
        $workflowExecutorEvent->setExecutor($executor);
57
        $workflowExecutorEvent->setTarget($executor);
58
59
        $this->getEventManager()->trigger($workflowExecutorEvent);
60
    }
61
62
63
    /**
64
     * {@inheritdoc}
65
     * @throws \Nnx\DoctrineFixtureModule\Executor\Exception\RuntimeException
66
     */
67
    public function bulkPurge(BulkFixtureEvent $event)
68
    {
69
        $workflowExecutorEvent = clone $this->getPrototypeEvent();
70
        $workflowExecutorEvent->setName(FixtureExecutorEvent::START_EXECUTE_FIXTURES_EVENT);
71
        $workflowExecutorEvent->setMethod(FixtureExecutorEvent::PURGE);
72
        $executor = $this->getExecutor();
73
        $workflowExecutorEvent->setExecutor($executor);
74
        $workflowExecutorEvent->setTarget($executor);
75
76
        $this->getEventManager()->trigger($workflowExecutorEvent);
77
    }
78
}
79