Skip to content

Commit b73a44e

Browse files
committed
Support multiple connections config
1 parent 9c21fd6 commit b73a44e

14 files changed

+458
-63
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88

99
## [Unreleased](https://github.com/inspirum/balikobot-php-symfony/compare/v1.0.0...master)
10+
### Added
11+
- Added support for multiple client connections with [**ServiceContainerRegistry**](https://github.com/inspirum/balikobot-php/blob/master/src/Service/Registry/ServiceContainerRegistry.php) service
1012

1113

1214
## v1.0.0 (2022-08-19)

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,38 @@ Configure client credentials by adding `config/packages/balikobot.yaml` and sett
3232

3333
```yaml
3434
balikobot:
35-
api_user: '%env(resolve:BALIKOBOT_API_USER)%'
36-
api_key: '%env(resolve:BALIKOBOT_API_KEY)%'
35+
connections:
36+
default:
37+
api_user: '%env(resolve:BALIKOBOT_API_USER)%'
38+
api_key: '%env(resolve:BALIKOBOT_API_KEY)%'
39+
```
40+
41+
You can use multiple client credentials
42+
43+
```yaml
44+
balikobot:
45+
connections:
46+
client1:
47+
api_user: '%env(resolve:BALIKOBOT_API_USER_1)%'
48+
api_key: '%env(resolve:BALIKOBOT_API_KEY_1)%'
49+
client2:
50+
api_user: '%env(resolve:BALIKOBOT_API_USER_2)%'
51+
api_key: '%env(resolve:BALIKOBOT_API_KEY_2)%'
52+
client3:
53+
api_user: '%env(resolve:BALIKOBOT_API_USER_3)%'
54+
api_key: '%env(resolve:BALIKOBOT_API_KEY_3)%'
55+
```
56+
57+
Then use `ServiceContainerRegistry` to get `ServiceContainer` for given connection.
58+
59+
```php
60+
/** @var Inspirum\Balikobot\Service\Registry\ServiceContainerRegistry $registry */
61+
62+
// get package service for default (or first) connection
63+
$packageService = $registry->get()->getPackageService();
64+
65+
// get branch service for "client3" connection
66+
$packageService = $registry->get('client3')->getBranchService();
3767
```
3868

3969
## Contributing

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
"ext-curl": "*",
2424
"ext-json": "*",
2525
"guzzlehttp/psr7": "^2.0",
26-
"inspirum/arrayable": "^1.1",
27-
"inspirum/balikobot": "^7.0",
26+
"inspirum/arrayable": "^1.2",
27+
"inspirum/balikobot": "dev-master",
2828
"psr/http-message": "^1.0",
2929
"symfony/config": "^6.1",
3030
"symfony/dependency-injection": "^6.1",
3131
"symfony/http-kernel": "^6.1"
3232
},
3333
"require-dev": {
3434
"inspirum/coding-standard": "^1.3",
35-
"phpstan/phpstan": "^1.9",
35+
"phpstan/phpstan": "^1.10",
3636
"phpunit/phpunit": "^10.0",
3737
"squizlabs/php_codesniffer": "^3.7",
3838
"symfony/yaml": "^6.1"

phpstan.neon.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ parameters:
55
paths:
66
- src
77
- tests
8-
ignoreErrors: []
8+
ignoreErrors:
9+
-
10+
message: '#^Cannot call method scalarNode\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\.$#'
11+
count: 1
12+
path: src/BalikobotBundle.php

phpunit.xml.dist

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
</testsuite>
1313
</testsuites>
1414
<coverage>
15-
<include>
16-
<directory suffix=".php">src</directory>
17-
</include>
1815
<report>
1916
<clover outputFile="var/phpunit/logs/clover.xml"/>
2017
<text outputFile="var/phpunit/coverage/coverage.txt"/>
2118
</report>
2219
</coverage>
20+
<source>
21+
<include>
22+
<directory>src</directory>
23+
</include>
24+
</source>
2325
</phpunit>

0 commit comments

Comments
 (0)