Skip to content

Commit 818cb74

Browse files
Merge pull request #6 from MacPaw/develop
Release
2 parents 5077b98 + 7e3c07c commit 818cb74

File tree

5 files changed

+60
-12
lines changed

5 files changed

+60
-12
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 MacPaw Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ Enable the bundle by adding it to the list of registered bundles in ```config/bu
2323
<?php
2424
2525
return [
26-
Macpaw\SchemaContextBundle\SchemaContextBundle::class => ['all' => true],
27-
Macpaw\SchemaContextBundle\PostgresSchemaBundle::class => ['all' => true],
28-
// ...
29-
];
26+
// ...
27+
Macpaw\SchemaContextBundle\SchemaContextBundle::class => ['all' => true],
28+
Macpaw\PostgresSchemaBundle\PostgresSchemaBundle::class => ['all' => true],
29+
];
3030
```
3131

3232
## Configuration
@@ -41,6 +41,33 @@ doctrine:
4141
default:
4242
wrapper_class: Macpaw\PostgresSchemaBundle\Doctrine\SchemaConnection
4343
```
44+
45+
Set `BaggageSchemaResolver` to `SchemaConnection` at kernel boot
46+
```php
47+
# src/Kernel.php
48+
49+
use Macpaw\PostgresSchemaBundle\Doctrine\SchemaConnection;
50+
use Macpaw\SchemaContextBundle\Service\BaggageSchemaResolver;
51+
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
52+
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
53+
54+
class Kernel extends BaseKernel
55+
{
56+
use MicroKernelTrait;
57+
58+
public function boot(): void
59+
{
60+
parent::boot();
61+
62+
SchemaConnection::setSchemaResolver(
63+
$this->getContainer()->get(BaggageSchemaResolver::class),
64+
);
65+
}
66+
67+
// ...
68+
}
69+
```
70+
4471
Make sure you configure the context bundle properly:
4572

4673
See https://github.com/MacPaw/schema-context-bundle/blob/develop/README.md

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"doctrine/orm": "^2.17 || ^3.0",
1919
"symfony/doctrine-bridge": "^6.4 || ^7.0",
2020
"doctrine/dbal": "^3.4",
21-
"macpaw/schema-context-bundle": "^1.0"
21+
"macpaw/schema-context-bundle": "^1.1"
2222
},
2323
"require-dev": {
2424
"phpstan/phpstan": "^1.10",

src/Doctrine/SchemaConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use Doctrine\DBAL\Connection as DBALConnection;
88
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
99
use Macpaw\PostgresSchemaBundle\Exception\UnsupportedPlatformException;
10-
use Macpaw\SchemaContextBundle\Service\SchemaResolver;
10+
use Macpaw\SchemaContextBundle\Service\BaggageSchemaResolver;
1111

1212
class SchemaConnection extends DBALConnection
1313
{
14-
private static ?SchemaResolver $schemaResolver = null;
14+
private static ?BaggageSchemaResolver $schemaResolver = null;
1515

16-
public static function setSchemaResolver(SchemaResolver $resolver): void
16+
public static function setSchemaResolver(BaggageSchemaResolver $resolver): void
1717
{
1818
self::$schemaResolver = $resolver;
1919
}

tests/Doctrine/SchemaConnectionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Doctrine\DBAL\Platforms\MySQLPlatform;
1414
use Macpaw\PostgresSchemaBundle\Doctrine\SchemaConnection;
1515
use Macpaw\PostgresSchemaBundle\Exception\UnsupportedPlatformException;
16-
use Macpaw\SchemaContextBundle\Service\SchemaResolver;
16+
use Macpaw\SchemaContextBundle\Service\BaggageSchemaResolver;
1717
use PHPUnit\Framework\TestCase;
1818

1919
class SchemaConnectionTest extends TestCase
@@ -39,7 +39,7 @@ public function testConnectSetsSearchPath(): void
3939
$connection->method('getDatabasePlatform')->willReturn($platform);
4040
$connection->method('fetchOne')->willReturn(true);
4141

42-
$resolver = new SchemaResolver();
42+
$resolver = new BaggageSchemaResolver();
4343

4444
$resolver->setSchema('test_schema');
4545

@@ -59,7 +59,7 @@ public function testConnectSkipsWhenNoSchema(): void
5959
$driver->method('connect')->willReturn($driverConnection);
6060

6161
$connection = new SchemaConnection([], $driver, new Configuration());
62-
$resolver = new SchemaResolver();
62+
$resolver = new BaggageSchemaResolver();
6363

6464
SchemaConnection::setSchemaResolver($resolver);
6565

@@ -83,7 +83,7 @@ public function testThrowsForUnsupportedPlatform(): void
8383

8484
$connection->method('getDatabasePlatform')->willReturn($platform);
8585

86-
$resolver = new SchemaResolver();
86+
$resolver = new BaggageSchemaResolver();
8787

8888
$resolver->setSchema('test_schema');
8989

0 commit comments

Comments
 (0)