4
4
5
5
namespace Sentry \SentryBundle \Tracing \Doctrine \DBAL ;
6
6
7
- use Doctrine \DBAL \Connection ;
8
7
use Doctrine \DBAL \Driver ;
9
- use Doctrine \DBAL \Driver \API \ExceptionConverter ;
10
- use Doctrine \DBAL \Platforms \AbstractPlatform ;
11
- use Doctrine \DBAL \Schema \AbstractSchemaManager ;
12
- use Doctrine \DBAL \VersionAwarePlatformDriver ;
8
+ use Doctrine \DBAL \Driver \Middleware \AbstractDriverMiddleware ;
13
9
14
10
/**
15
11
* This is a simple implementation of the {@see Driver} interface that decorates
20
16
*
21
17
* @phpstan-import-type Params from \Doctrine\DBAL\DriverManager as ConnectionParams
22
18
*/
23
- final class TracingDriverForV3 implements Driver, VersionAwarePlatformDriver
19
+ final class TracingDriverForV3 extends AbstractDriverMiddleware
24
20
{
25
21
/**
26
22
* @var TracingDriverConnectionFactoryInterface The connection factory
27
23
*/
28
24
private $ connectionFactory ;
29
25
30
- /**
31
- * @var Driver|VersionAwarePlatformDriver The instance of the decorated driver
32
- */
33
- private $ decoratedDriver ;
34
-
35
26
/**
36
27
* Constructor.
37
28
*
@@ -40,8 +31,9 @@ final class TracingDriverForV3 implements Driver, VersionAwarePlatformDriver
40
31
*/
41
32
public function __construct (TracingDriverConnectionFactoryInterface $ connectionFactory , Driver $ decoratedDriver )
42
33
{
34
+ parent ::__construct ($ decoratedDriver );
35
+
43
36
$ this ->connectionFactory = $ connectionFactory ;
44
- $ this ->decoratedDriver = $ decoratedDriver ;
45
37
}
46
38
47
39
/**
@@ -52,51 +44,9 @@ public function __construct(TracingDriverConnectionFactoryInterface $connectionF
52
44
public function connect (array $ params ): TracingDriverConnectionInterface
53
45
{
54
46
return $ this ->connectionFactory ->create (
55
- $ this -> decoratedDriver -> connect ($ params ),
56
- $ this ->decoratedDriver -> getDatabasePlatform (),
47
+ parent :: connect ($ params ),
48
+ $ this ->getDatabasePlatform (),
57
49
$ params
58
50
);
59
51
}
60
-
61
- /**
62
- * {@inheritdoc}
63
- */
64
- public function getDatabasePlatform (): AbstractPlatform
65
- {
66
- return $ this ->decoratedDriver ->getDatabasePlatform ();
67
- }
68
-
69
- /**
70
- * {@inheritdoc}
71
- *
72
- * @phpstan-template T of AbstractPlatform
73
- *
74
- * @phpstan-param T $platform
75
- *
76
- * @phpstan-return AbstractSchemaManager<T>
77
- */
78
- public function getSchemaManager (Connection $ conn , AbstractPlatform $ platform ): AbstractSchemaManager
79
- {
80
- return $ this ->decoratedDriver ->getSchemaManager ($ conn , $ platform );
81
- }
82
-
83
- /**
84
- * {@inheritdoc}
85
- */
86
- public function getExceptionConverter (): ExceptionConverter
87
- {
88
- return $ this ->decoratedDriver ->getExceptionConverter ();
89
- }
90
-
91
- /**
92
- * {@inheritdoc}
93
- */
94
- public function createDatabasePlatformForVersion ($ version ): AbstractPlatform
95
- {
96
- if ($ this ->decoratedDriver instanceof VersionAwarePlatformDriver) {
97
- return $ this ->decoratedDriver ->createDatabasePlatformForVersion ($ version );
98
- }
99
-
100
- return $ this ->getDatabasePlatform ();
101
- }
102
52
}
0 commit comments