1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ODM\MongoDB\Event; |
6
|
|
|
|
7
|
|
|
use Doctrine\ODM\MongoDB\DocumentManager; |
8
|
|
|
use const E_USER_DEPRECATED; |
9
|
|
|
use function sprintf; |
10
|
|
|
use function trigger_error; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Provides event arguments for the documentNotFound event. |
14
|
|
|
* |
15
|
|
|
* @final |
16
|
|
|
*/ |
17
|
|
|
class DocumentNotFoundEventArgs extends LifecycleEventArgs |
18
|
|
|
{ |
19
|
|
|
/** @var mixed */ |
20
|
|
|
private $identifier; |
21
|
|
|
|
22
|
|
|
/** @var bool */ |
23
|
|
|
private $disableException = false; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param mixed $identifier |
27
|
|
|
*/ |
28
|
9 |
|
public function __construct(object $document, DocumentManager $dm, $identifier) |
29
|
|
|
{ |
30
|
9 |
|
if (self::class !== static::class) { |
31
|
|
|
@trigger_error(sprintf('The class "%s" extends "%s" which will be final in MongoDB ODM 2.0.', static::class, self::class), E_USER_DEPRECATED); |
|
|
|
|
32
|
|
|
} |
33
|
9 |
|
parent::__construct($document, $dm); |
34
|
9 |
|
$this->identifier = $identifier; |
35
|
9 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Retrieve associated identifier. |
39
|
|
|
* |
40
|
|
|
* @return mixed |
41
|
|
|
*/ |
42
|
|
|
public function getIdentifier() |
43
|
|
|
{ |
44
|
|
|
return $this->identifier; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Indicates whether the proxy initialization exception is disabled. |
49
|
|
|
*/ |
50
|
9 |
|
public function isExceptionDisabled() : bool |
51
|
|
|
{ |
52
|
9 |
|
return $this->disableException; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Disable the throwing of an exception |
57
|
|
|
* |
58
|
|
|
* This method indicates to the proxy initializer that the missing document |
59
|
|
|
* has been handled and no exception should be thrown. This can't be reset. |
60
|
|
|
*/ |
61
|
1 |
|
public function disableException(bool $disableException = true) : void |
62
|
|
|
{ |
63
|
1 |
|
$this->disableException = $disableException; |
64
|
1 |
|
} |
65
|
|
|
} |
66
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: