1 | <?php |
||
2 | |||
3 | namespace Oliverde8\PhpEtlBundle\EventSubscriber; |
||
4 | |||
5 | use Doctrine\ORM\EntityManagerInterface; |
||
0 ignored issues
–
show
|
|||
6 | use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityPersistedEvent; |
||
0 ignored issues
–
show
The type
EasyCorp\Bundle\EasyAdmi...terEntityPersistedEvent was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityPersistedEvent; |
||
0 ignored issues
–
show
The type
EasyCorp\Bundle\EasyAdmi...oreEntityPersistedEvent was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
8 | use Oliverde8\PhpEtlBundle\Entity\EtlExecution; |
||
9 | use Oliverde8\PhpEtlBundle\Message\EtlExecutionMessage; |
||
10 | use Oliverde8\PhpEtlBundle\Services\ChainProcessorsManager; |
||
11 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
12 | use Symfony\Component\Messenger\MessageBusInterface; |
||
13 | |||
14 | class EtlExecutionEventSubscriber implements EventSubscriberInterface |
||
15 | { |
||
16 | /** @var EntityManagerInterface */ |
||
17 | protected $em; |
||
18 | |||
19 | /** @var ChainProcessorsManager */ |
||
20 | protected $chainProcessorManager; |
||
21 | |||
22 | /** @var MessageBusInterface */ |
||
23 | protected $messageBus; |
||
24 | |||
25 | /** |
||
26 | * EtlExecutionEventSubscriber constructor. |
||
27 | * @param EntityManagerInterface $em |
||
28 | * @param ChainProcessorsManager $chainProcessorManager |
||
29 | * @param MessageBusInterface $messageBus |
||
30 | */ |
||
31 | public function __construct(EntityManagerInterface $em, ChainProcessorsManager $chainProcessorManager, ?MessageBusInterface $messageBus =null) |
||
32 | { |
||
33 | $this->em = $em; |
||
34 | $this->chainProcessorManager = $chainProcessorManager; |
||
35 | $this->messageBus = $messageBus; |
||
36 | } |
||
37 | |||
38 | public static function getSubscribedEvents() |
||
39 | { |
||
40 | return [ |
||
41 | BeforeEntityPersistedEvent::class => ['setChainDetails'], |
||
42 | AfterEntityPersistedEvent::class => ['queueChainExecution'], |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | public function setChainDetails(BeforeEntityPersistedEvent $event) |
||
47 | { |
||
48 | $entity = $event->getEntityInstance(); |
||
49 | if (!$entity instanceof EtlExecution) { |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | $definition = $this->chainProcessorManager->getRawDefinition($entity->getName()); |
||
54 | $entity->setDefinition($definition); |
||
55 | $entity->setStatus(EtlExecution::STATUS_WAITING); |
||
56 | } |
||
57 | |||
58 | public function queueChainExecution(AfterEntityPersistedEvent $event) |
||
59 | { |
||
60 | $entity = $event->getEntityInstance(); |
||
61 | if (!$entity instanceof EtlExecution) { |
||
62 | return; |
||
63 | } |
||
64 | |||
65 | try { |
||
66 | $this->messageBus->dispatch(new EtlExecutionMessage($entity->getId())); |
||
67 | } catch (\Exception $e) { |
||
68 | $this->em->remove($entity); |
||
69 | $this->em->flush(); |
||
70 | |||
71 | throw $e; |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths