1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Isolate\Framework\UnitOfWork; |
4
|
|
|
|
5
|
|
|
use Isolate\Framework\UnitOfWork\Entity\DefinitionCollection; |
6
|
|
|
use Isolate\Framework\UnitOfWork\Entity\IsolateComparer; |
7
|
|
|
use Isolate\Framework\UnitOfWork\Entity\IsolateIdentifier; |
8
|
|
|
use Isolate\Framework\UnitOfWork\Object\IsolateRegistry; |
9
|
|
|
use Isolate\UnitOfWork\CommandBus\SilentBus; |
10
|
|
|
use Isolate\UnitOfWork\Entity\ChangeBuilder; |
11
|
|
|
use Isolate\UnitOfWork\Entity\Definition\Repository\InMemory; |
12
|
|
|
use Isolate\UnitOfWork\Factory as UnitOfWorkFactory; |
13
|
|
|
use Isolate\UnitOfWork\Object\PropertyCloner; |
14
|
|
|
use Isolate\UnitOfWork\Object\SnapshotMaker\Adapter\DeepCopy\SnapshotMaker; |
15
|
|
|
use Isolate\UnitOfWork\UnitOfWork; |
16
|
|
|
|
17
|
|
|
class Factory implements UnitOfWorkFactory |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var DefinitionCollection |
21
|
|
|
*/ |
22
|
|
|
private $entityDefinitions; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param DefinitionCollection $entityDefinitions |
26
|
|
|
*/ |
27
|
|
|
public function __construct(DefinitionCollection $entityDefinitions) |
28
|
|
|
{ |
29
|
|
|
$this->entityDefinitions = $entityDefinitions; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return UnitOfWork |
34
|
|
|
*/ |
35
|
|
|
public function create() |
36
|
|
|
{ |
37
|
|
|
$definitionRepository = new InMemory($this->entityDefinitions); |
|
|
|
|
38
|
|
|
$snapshotMaker = new SnapshotMaker(); |
39
|
|
|
$recoveryPoint = new PropertyCloner(); |
40
|
|
|
$objectRegistry = new IsolateRegistry($snapshotMaker, $recoveryPoint); |
41
|
|
|
$identifier = new IsolateIdentifier($definitionRepository); |
42
|
|
|
$changeBuilder = new ChangeBuilder($definitionRepository, $identifier); |
43
|
|
|
$comparer = new IsolateComparer($definitionRepository); |
44
|
|
|
$commandBus = new SilentBus($definitionRepository); |
45
|
|
|
|
46
|
|
|
return new UnitOfWork( |
47
|
|
|
$objectRegistry, |
48
|
|
|
$identifier, |
49
|
|
|
$changeBuilder, |
50
|
|
|
$comparer, |
51
|
|
|
$commandBus |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: