|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Ray\AuraSqlModule; |
|
6
|
|
|
|
|
7
|
|
|
use Aura\Sql\ConnectionLocatorInterface; |
|
8
|
|
|
use Aura\Sql\ExtendedPdoInterface; |
|
9
|
|
|
use Override; |
|
10
|
|
|
use Ray\AuraSqlModule\Annotation\ReadOnlyConnection; |
|
11
|
|
|
use Ray\AuraSqlModule\Annotation\WriteConnection; |
|
12
|
|
|
use Ray\Di\AbstractModule; |
|
13
|
|
|
use Ray\Di\Scope; |
|
14
|
|
|
|
|
15
|
|
|
final class AuraSqlReplicationModule extends AbstractModule |
|
16
|
|
|
{ |
|
17
|
|
|
public function __construct( |
|
18
|
|
|
private readonly ConnectionLocatorInterface $connectionLocator, |
|
19
|
|
|
private readonly string $qualifer = '', |
|
20
|
|
|
?AbstractModule $module = null |
|
21
|
|
|
) { |
|
22
|
|
|
parent::__construct($module); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritDoc} |
|
27
|
|
|
*/ |
|
28
|
8 |
|
#[Override] |
|
29
|
|
|
protected function configure(): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->bind(ConnectionLocatorInterface::class) |
|
32
|
|
|
->annotatedWith($this->qualifer) |
|
33
|
8 |
|
->toInstance($this->connectionLocator); |
|
34
|
8 |
|
|
|
35
|
8 |
|
// ReadOnlyConnection when GET, otherwise WriteConnection |
|
36
|
8 |
|
$this->bind(ExtendedPdoInterface::class) |
|
37
|
|
|
->annotatedWith($this->qualifer) |
|
38
|
|
|
->toProvider(AuraSqlReplicationDbProvider::class, $this->qualifer) |
|
39
|
|
|
->in(Scope::SINGLETON); |
|
40
|
|
|
|
|
41
|
8 |
|
// @ReadOnlyConnection @WriteConnection |
|
42
|
|
|
$this->installReadWriteConnection(); |
|
43
|
8 |
|
} |
|
44
|
8 |
|
|
|
45
|
|
|
protected function installReadWriteConnection(): void |
|
46
|
|
|
{ |
|
47
|
8 |
|
// @ReadOnlyConnection |
|
48
|
|
|
$this->bindInterceptor( |
|
49
|
8 |
|
$this->matcher->any(), |
|
50
|
|
|
$this->matcher->annotatedWith(ReadOnlyConnection::class), |
|
51
|
8 |
|
[AuraSqlSlaveDbInterceptor::class], |
|
|
|
|
|
|
52
|
8 |
|
); |
|
53
|
|
|
// @WriteConnection |
|
54
|
8 |
|
$this->bindInterceptor( |
|
55
|
|
|
$this->matcher->any(), |
|
56
|
|
|
$this->matcher->annotatedWith(WriteConnection::class), |
|
57
|
8 |
|
[AuraSqlMasterDbInterceptor::class], |
|
|
|
|
|
|
58
|
8 |
|
); |
|
59
|
8 |
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
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