Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb665be

Browse files
GromNaNfabpot
authored andcommitted
[Cache] Split PdoAdapter into DoctrineDbalAdapter
1 parentd468bfd commitdb665be

19 files changed

+984
-230
lines changed

‎UPGRADE-5.4.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Cache
55
-----
66

77
* Deprecate`DoctrineProvider` and`DoctrineAdapter` because these classes have been added to the`doctrine/cache` package
8+
* Deprecate usage of`PdoAdapter` with a`Doctrine\DBAL\Connection` or a DBAL URL. Use the new`DoctrineDbalAdapter` instead
89

910
Console
1011
-------

‎UPGRADE-6.0.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Cache
1515
-----
1616

1717
* Remove`DoctrineProvider` and`DoctrineAdapter` because these classes have been added to the`doctrine/cache` package
18+
*`PdoAdapter` does not accept`Doctrine\DBAL\Connection` or DBAL URL. Use the new`DoctrineDbalAdapter` instead
1819

1920
Config
2021
------

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"doctrine/cache":"^1.11|^2.0",
130130
"doctrine/collections":"~1.0",
131131
"doctrine/data-fixtures":"^1.1",
132-
"doctrine/dbal":"^2.13|^3.0",
132+
"doctrine/dbal":"^2.13.1|^3.0",
133133
"doctrine/orm":"^2.7.3",
134134
"guzzlehttp/promises":"^1.4",
135135
"masterminds/html5":"^2.6",
@@ -155,7 +155,7 @@
155155
"ext-psr":"<1.1|>=2",
156156
"async-aws/core":"<1.5",
157157
"doctrine/annotations":"<1.13.1",
158-
"doctrine/dbal":"<2.13",
158+
"doctrine/dbal":"<2.13.1",
159159
"egulias/email-validator":"~3.0.0",
160160
"masterminds/html5":"<2.6",
161161
"phpdocumentor/reflection-docblock":"<3.2.2",

‎src/Symfony/Bridge/Doctrine/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add`DoctrineOpenTransactionLoggerMiddleware` to log when a transaction has been left open
8+
* Deprecate`PdoCacheAdapterDoctrineSchemaSubscriber` and add`DoctrineDbalCacheAdapterSchemaSubscriber` instead
89

910
5.3
1011
---
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Bridge\Doctrine\SchemaListener;
13+
14+
useDoctrine\Common\EventSubscriber;
15+
useDoctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
16+
useDoctrine\ORM\Tools\ToolEvents;
17+
useSymfony\Component\Cache\Adapter\DoctrineSchemaConfiguratorInterface;
18+
19+
/**
20+
* Automatically adds the cache table needed for the DoctrineDbalAdapter of
21+
* the Cache component.
22+
*
23+
* @author Ryan Weaver <ryan@symfonycasts.com>
24+
*/
25+
finalclass DoctrineDbalCacheAdapterSchemaSubscriberimplements EventSubscriber
26+
{
27+
private$dbalAdapters;
28+
29+
/**
30+
* @param iterable<mixed, DoctrineSchemaConfiguratorInterface> $dbalAdapters
31+
*/
32+
publicfunction__construct(iterable$dbalAdapters)
33+
{
34+
$this->dbalAdapters =$dbalAdapters;
35+
}
36+
37+
publicfunctionpostGenerateSchema(GenerateSchemaEventArgs$event):void
38+
{
39+
$dbalConnection =$event->getEntityManager()->getConnection();
40+
foreach ($this->dbalAdaptersas$dbalAdapter) {
41+
$dbalAdapter->configureSchema($event->getSchema(),$dbalConnection);
42+
}
43+
}
44+
45+
publicfunctiongetSubscribedEvents():array
46+
{
47+
if (!class_exists(ToolEvents::class)) {
48+
return [];
49+
}
50+
51+
return [
52+
ToolEvents::postGenerateSchema,
53+
];
54+
}
55+
}

‎src/Symfony/Bridge/Doctrine/SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriber.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
useDoctrine\ORM\Tools\ToolEvents;
1717
useSymfony\Component\Cache\Adapter\PdoAdapter;
1818

19+
trigger_deprecation('symfony/doctrine-bridge','5.4','The "%s" class is deprecated, use "%s" instead.', PdoCacheAdapterDoctrineSchemaSubscriber::class, DoctrineDbalCacheAdapterSchemaSubscriber::class);
20+
1921
/**
2022
* Automatically adds the cache table needed for the PdoAdapter.
2123
*
2224
* @author Ryan Weaver <ryan@symfonycasts.com>
25+
*
26+
* @deprecated since symfony 5.4 use DoctrineDbalCacheAdapterSchemaSubscriber
2327
*/
2428
finalclass PdoCacheAdapterDoctrineSchemaSubscriberimplements EventSubscriber
2529
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Bridge\Doctrine\Tests\SchemaListener;
13+
14+
useDoctrine\DBAL\Connection;
15+
useDoctrine\DBAL\Schema\Schema;
16+
useDoctrine\ORM\EntityManagerInterface;
17+
useDoctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
18+
usePHPUnit\Framework\TestCase;
19+
useSymfony\Bridge\Doctrine\SchemaListener\DoctrineDbalCacheAdapterSchemaSubscriber;
20+
useSymfony\Component\Cache\Adapter\DoctrineSchemaConfiguratorInterface;
21+
22+
class DoctrineDbalCacheAdapterSchemaSubscriberTestextends TestCase
23+
{
24+
publicfunctiontestPostGenerateSchema()
25+
{
26+
$schema =newSchema();
27+
$dbalConnection =$this->createMock(Connection::class);
28+
$entityManager =$this->createMock(EntityManagerInterface::class);
29+
$entityManager->expects($this->once())
30+
->method('getConnection')
31+
->willReturn($dbalConnection);
32+
$event =newGenerateSchemaEventArgs($entityManager,$schema);
33+
34+
$pdoAdapter =$this->createMock(DoctrineSchemaConfiguratorInterface::class);
35+
$pdoAdapter->expects($this->once())
36+
->method('configureSchema')
37+
->with($schema,$dbalConnection);
38+
39+
$subscriber =newDoctrineDbalCacheAdapterSchemaSubscriber([$pdoAdapter]);
40+
$subscriber->postGenerateSchema($event);
41+
}
42+
}

‎src/Symfony/Bridge/Doctrine/Tests/SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriberTest.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
useSymfony\Bridge\Doctrine\SchemaListener\PdoCacheAdapterDoctrineSchemaSubscriber;
2020
useSymfony\Component\Cache\Adapter\PdoAdapter;
2121

22+
/**
23+
* @group legacy
24+
*/
2225
class PdoCacheAdapterDoctrineSchemaSubscriberTestextends TestCase
2326
{
2427
publicfunctiontestPostGenerateSchema()

‎src/Symfony/Bridge/Doctrine/composer.json‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"require-dev": {
2929
"composer/package-versions-deprecated":"^1.8",
3030
"symfony/stopwatch":"^4.4|^5.0|^6.0",
31-
"symfony/cache":"^5.1|^6.0",
31+
"symfony/cache":"^5.4|^6.0",
3232
"symfony/config":"^4.4|^5.0|^6.0",
3333
"symfony/dependency-injection":"^4.4|^5.0|^6.0",
3434
"symfony/form":"^5.1.3|^6.0",
@@ -47,14 +47,15 @@
4747
"doctrine/annotations":"^1.10.4",
4848
"doctrine/collections":"~1.0",
4949
"doctrine/data-fixtures":"^1.1",
50-
"doctrine/dbal":"^2.13|^3.0",
50+
"doctrine/dbal":"^2.13.1|^3.0",
5151
"doctrine/orm":"^2.7.3",
5252
"psr/log":"^1|^2|^3"
5353
},
5454
"conflict": {
55-
"doctrine/dbal":"<2.13",
55+
"doctrine/dbal":"<2.13.1",
5656
"doctrine/orm":"<2.7.3",
5757
"phpunit/phpunit":"<5.4.3",
58+
"symfony/cache":"<5.4",
5859
"symfony/dependency-injection":"<4.4",
5960
"symfony/form":"<5.1",
6061
"symfony/http-kernel":"<5",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp