|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Yii\Debug\Collector\Database; |
|
6
|
|
|
|
|
7
|
|
|
use Cycle\ORM\FactoryInterface; |
|
8
|
|
|
use Cycle\ORM\Heap\HeapInterface; |
|
9
|
|
|
use Cycle\ORM\Heap\Node; |
|
10
|
|
|
use Cycle\ORM\MapperInterface; |
|
11
|
|
|
use Cycle\ORM\ORMInterface; |
|
12
|
|
|
use Cycle\ORM\RelationMap; |
|
13
|
|
|
use Cycle\ORM\RepositoryInterface; |
|
14
|
|
|
use Cycle\ORM\Select\SourceInterface; |
|
15
|
|
|
use Cycle\ORM\Transaction\CommandGeneratorInterface; |
|
16
|
|
|
|
|
17
|
|
|
final class CycleORMInterfaceProxy implements ORMInterface |
|
18
|
|
|
{ |
|
19
|
|
|
public function __construct( |
|
20
|
|
|
private ORMInterface $orm, |
|
21
|
|
|
private CycleCollector $collector |
|
22
|
|
|
) { |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function get(string $role, array $scope, bool $load = true): ?object |
|
26
|
|
|
{ |
|
27
|
|
|
$this->collector->collect('get', $role, $scope, $load); |
|
28
|
|
|
return $this->orm->get($role, $scope, $load); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getIndexes(string $entity): array |
|
32
|
|
|
{ |
|
33
|
|
|
$this->collector->collect('getIndexes', $entity); |
|
34
|
|
|
return $this->orm->getIndexes($entity); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function resolveRole(object|string $entity): string |
|
38
|
|
|
{ |
|
39
|
|
|
$this->collector->collect('resolveRole', $entity); |
|
40
|
|
|
return $this->orm->resolveRole($entity); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function make(string $role, array $data = [], int $status = Node::NEW, bool $typecast = false): object |
|
44
|
|
|
{ |
|
45
|
|
|
$this->collector->collect('make', $role, $data, $status, $typecast); |
|
46
|
|
|
return $this->orm->make($role, $data, $status, $typecast); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getFactory(): FactoryInterface |
|
50
|
|
|
{ |
|
51
|
|
|
$this->collector->collect('getFactory'); |
|
52
|
|
|
return $this->orm->getFactory(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getCommandGenerator(): CommandGeneratorInterface |
|
56
|
|
|
{ |
|
57
|
|
|
$this->collector->collect('getCommandGenerator'); |
|
58
|
|
|
return $this->orm->getCommandGenerator(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getService(string $class): object |
|
62
|
|
|
{ |
|
63
|
|
|
$this->collector->collect('getService', $class); |
|
64
|
|
|
return $this->orm->getService($class); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getSchema(): \Cycle\ORM\SchemaInterface |
|
68
|
|
|
{ |
|
69
|
|
|
$this->collector->collect('getSchema'); |
|
70
|
|
|
return $this->orm->getSchema(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getHeap(): HeapInterface |
|
74
|
|
|
{ |
|
75
|
|
|
$this->collector->collect('getHeap'); |
|
76
|
|
|
return $this->orm->getHeap(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function with( |
|
80
|
|
|
?\Cycle\ORM\SchemaInterface $schema = null, |
|
81
|
|
|
?FactoryInterface $factory = null, |
|
82
|
|
|
?HeapInterface $heap = null |
|
83
|
|
|
): ORMInterface { |
|
84
|
|
|
$this->collector->collect('with', $schema, $factory, $heap); |
|
85
|
|
|
return new self($this->orm->with($schema, $factory, $heap), $this->collector); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function getMapper(object|string $entity): MapperInterface |
|
89
|
|
|
{ |
|
90
|
|
|
$this->collector->collect('getMapper', $entity); |
|
91
|
|
|
return $this->orm->getMapper($entity); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function getRepository(object|string $entity): RepositoryInterface |
|
95
|
|
|
{ |
|
96
|
|
|
// var_dump($this->orm); |
|
97
|
|
|
// exit(); |
|
98
|
|
|
// throw new \InvalidArgumentException(); |
|
99
|
|
|
$this->collector->collect('getRepository', $entity); |
|
100
|
|
|
return $this->orm->getRepository($entity); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function getRelationMap(string $entity): RelationMap |
|
104
|
|
|
{ |
|
105
|
|
|
$this->collector->collect('getRelationMap', $entity); |
|
106
|
|
|
return $this->orm->getRelationMap($entity); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getSource(string $entity): SourceInterface |
|
110
|
|
|
{ |
|
111
|
|
|
$this->collector->collect('getSource', $entity); |
|
112
|
|
|
return $this->orm->getSource($entity); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|