|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Arp\DoctrineEntityRepository\Persistence\Event; |
|
6
|
|
|
|
|
7
|
|
|
use Arp\DoctrineEntityRepository\Persistence\PersistServiceInterface; |
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
9
|
|
|
use Psr\Log\LoggerInterface; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @author Alex Patterson <[email protected]> |
|
13
|
|
|
* @package Arp\DoctrineEntityRepository\Persistence\Event |
|
14
|
|
|
*/ |
|
15
|
|
|
class EntityErrorEvent extends AbstractEntityEvent |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var \Throwable|null |
|
19
|
|
|
*/ |
|
20
|
|
|
private ?\Throwable $exception; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param string $eventName |
|
24
|
|
|
* @param PersistServiceInterface $persistService |
|
25
|
|
|
* @param EntityManagerInterface $entityManager |
|
26
|
|
|
* @param LoggerInterface $logger |
|
27
|
|
|
* @param \Throwable|null $exception |
|
28
|
|
|
* @param array<string|int, mixed> $params |
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct( |
|
31
|
|
|
string $eventName, |
|
32
|
|
|
PersistServiceInterface $persistService, |
|
33
|
|
|
EntityManagerInterface $entityManager, |
|
34
|
|
|
LoggerInterface $logger, |
|
35
|
|
|
?\Throwable $exception = null, |
|
36
|
|
|
array $params = [] |
|
37
|
|
|
) { |
|
38
|
|
|
parent::__construct($eventName, $persistService, $entityManager, $logger, $params); |
|
39
|
|
|
|
|
40
|
|
|
$this->exception = $exception; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return bool |
|
45
|
|
|
*/ |
|
46
|
|
|
public function hasException(): bool |
|
47
|
|
|
{ |
|
48
|
|
|
return isset($this->exception); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return \Throwable|null |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getException(): ?\Throwable |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->exception; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param \Throwable $exception |
|
61
|
|
|
*/ |
|
62
|
|
|
public function setException(\Throwable $exception): void |
|
63
|
|
|
{ |
|
64
|
|
|
$this->exception = $exception; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|