1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\Foundry; |
4
|
|
|
|
5
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
6
|
|
|
use Doctrine\Persistence\ObjectManager; |
7
|
|
|
use Doctrine\Persistence\ObjectRepository; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @internal |
11
|
|
|
*/ |
12
|
|
|
final class ChainManagerRegistry implements ManagerRegistry |
13
|
|
|
{ |
14
|
|
|
/** @var list<ManagerRegistry> */ |
|
|
|
|
15
|
|
|
private $managerRegistries; |
16
|
|
|
|
17
|
|
|
/** @param list<ManagerRegistry> $managerRegistries */ |
18
|
|
|
public function __construct(array $managerRegistries) |
19
|
|
|
{ |
20
|
|
|
if (0 === \count($managerRegistries)) { |
21
|
|
|
throw new \InvalidArgumentException('no manager registry provided'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$this->managerRegistries = $managerRegistries; |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function getRepository($persistentObject, $persistentManagerName = null): ObjectRepository |
28
|
|
|
{ |
29
|
|
|
foreach ($this->managerRegistries as $managerRegistry) { |
30
|
|
|
if ($repository = $managerRegistry->getRepository($persistentObject, $persistentManagerName)) { |
31
|
|
|
return $repository; |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
throw new \LogicException("Cannot find repository for class {$persistentObject}"); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function getManagerForClass($class): ?ObjectManager |
39
|
|
|
{ |
40
|
|
|
foreach ($this->managerRegistries as $managerRegistry) { |
41
|
|
|
if ($managerForClass = $managerRegistry->getManagerForClass($class)) { |
42
|
|
|
return $managerForClass; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return null; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getManagers(): array |
50
|
|
|
{ |
51
|
|
|
return \array_reduce( |
52
|
|
|
$this->managerRegistries, |
|
|
|
|
53
|
|
|
static function(array $carry, ManagerRegistry $managerRegistry) { |
54
|
|
|
return \array_merge($carry, $managerRegistry->getManagers()); |
55
|
|
|
}, |
56
|
|
|
[] |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getDefaultConnectionName() |
61
|
|
|
{ |
62
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getConnection($name = null) |
66
|
|
|
{ |
67
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getConnections() |
71
|
|
|
{ |
72
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getConnectionNames() |
76
|
|
|
{ |
77
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getDefaultManagerName() |
81
|
|
|
{ |
82
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getManager($name = null) |
86
|
|
|
{ |
87
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function resetManager($name = null) |
91
|
|
|
{ |
92
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getAliasNamespace($alias) |
96
|
|
|
{ |
97
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getManagerNames() |
101
|
|
|
{ |
102
|
|
|
throw new \BadMethodCallException('Not available in '.self::class); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths