Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| ConnectionProvider | |
0.00% |
0 / 5 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPrimaryDatabase | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getReplicaDatabase | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| commitAndWaitForReplication | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getEmptyTransactionTicket | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace ContentTranslation; |
| 5 | |
| 6 | use Wikimedia\Rdbms\IConnectionProvider; |
| 7 | use Wikimedia\Rdbms\IDatabase; |
| 8 | use Wikimedia\Rdbms\IReadableDatabase; |
| 9 | |
| 10 | /** |
| 11 | * Decorator for IConnectionProvider that enforces the virtual-cx domain |
| 12 | */ |
| 13 | class ConnectionProvider implements IConnectionProvider { |
| 14 | public const VIRTUAL_DOMAIN = 'virtual-cx'; |
| 15 | |
| 16 | public function __construct( private readonly IConnectionProvider $inner ) { |
| 17 | } |
| 18 | |
| 19 | /** @inheritDoc */ |
| 20 | public function getPrimaryDatabase( $domain = false ): IDatabase { |
| 21 | return $this->inner->getPrimaryDatabase( self::VIRTUAL_DOMAIN ); |
| 22 | } |
| 23 | |
| 24 | /** @inheritDoc */ |
| 25 | public function getReplicaDatabase( $domain = false, $group = null ): IReadableDatabase { |
| 26 | return $this->inner->getReplicaDatabase( self::VIRTUAL_DOMAIN, $group ); |
| 27 | } |
| 28 | |
| 29 | /** @inheritDoc */ |
| 30 | public function commitAndWaitForReplication( $fname, $ticket, array $opts = [] ) { |
| 31 | return $this->inner->commitAndWaitForReplication( $fname, $ticket, $opts ); |
| 32 | } |
| 33 | |
| 34 | /** @inheritDoc */ |
| 35 | public function getEmptyTransactionTicket( $fname ) { |
| 36 | return $this->inner->getEmptyTransactionTicket( $fname ); |
| 37 | } |
| 38 | } |