Skip to content

Commit ff5b56e

Browse files
Merge branch 'develop' into chore/add-mit-license
2 parents bbebdb7 + 3c30a73 commit ff5b56e

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

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)