1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the API Platform project. |
5
|
|
|
* |
6
|
|
|
* |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
namespace ApiPlatform\Core\Mercure; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class EntitiesToPublish |
19
|
|
|
{ |
20
|
|
|
private $createdEntities; |
21
|
|
|
private $updatedEntities; |
22
|
|
|
private $deletedEntities; |
23
|
|
|
|
24
|
|
|
public function __construct() |
25
|
|
|
{ |
26
|
|
|
$this->reset(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function reset(): void |
30
|
|
|
{ |
31
|
|
|
$this->createdEntities = new \SplObjectStorage(); |
32
|
|
|
$this->updatedEntities = new \SplObjectStorage(); |
33
|
|
|
$this->deletedEntities = new \SplObjectStorage(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function addDeletedEntities($entity, $value){ |
37
|
|
|
$this->deletedEntities[$entity] = $value; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function addUpdatedEntities($entity, $value){ |
41
|
|
|
$this->updatedEntities[$entity] = $value; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function addCreatedEntities($entity, $value){ |
45
|
|
|
$this->createdEntities[$entity] = $value; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return mixed |
50
|
|
|
*/ |
51
|
|
|
public function getCreatedEntities() |
52
|
|
|
{ |
53
|
|
|
return $this->createdEntities; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return mixed |
58
|
|
|
*/ |
59
|
|
|
public function getUpdatedEntities() |
60
|
|
|
{ |
61
|
|
|
return $this->updatedEntities; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function getDeletedEntities() |
68
|
|
|
{ |
69
|
|
|
return $this->deletedEntities; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getCreatedEntityValue($entity){ |
73
|
|
|
return $this->createdEntities[$entity]; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getUpdatedEntityValue($entity){ |
77
|
|
|
return $this->updatedEntities[$entity]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getDeletedEntityValue($entity){ |
81
|
|
|
return $this->deletedEntities[$entity]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|