15
15
16
16
use Doctrine \Bundle \FixturesBundle \Loader \SymfonyFixturesLoader ;
17
17
use Doctrine \Common \DataFixtures \Executor \AbstractExecutor ;
18
- use Doctrine \DBAL \Connection ;
19
- use Doctrine \DBAL \Platforms \AbstractMySQLPlatform ;
20
- use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
21
- use Doctrine \DBAL \Platforms \SqlitePlatform ;
22
18
use Doctrine \Persistence \ManagerRegistry ;
23
19
use Doctrine \Persistence \ObjectManager ;
20
+ use Liip \TestFixturesBundle \FixturesLoaderFactoryInterface ;
24
21
use Liip \TestFixturesBundle \Services \DatabaseBackup \DatabaseBackupInterface ;
25
- use Liip \TestFixturesBundle \Services \FixturesLoaderFactory ;
26
22
use Symfony \Component \DependencyInjection \ContainerInterface ;
27
23
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
28
24
@@ -39,7 +35,7 @@ abstract class AbstractDatabaseTool
39
35
/** @var EventDispatcherInterface */
40
36
protected $ eventDispatcher ;
41
37
42
- protected $ fixturesLoaderFactory ;
38
+ protected FixturesLoaderFactoryInterface $ fixturesLoaderFactory ;
43
39
44
40
/**
45
41
* @var ManagerRegistry
@@ -61,8 +57,6 @@ abstract class AbstractDatabaseTool
61
57
*/
62
58
protected $ om ;
63
59
64
- protected Connection $ connection ;
65
-
66
60
/**
67
61
* @var int|null
68
62
*/
@@ -80,7 +74,7 @@ abstract class AbstractDatabaseTool
80
74
*/
81
75
private static $ cachedMetadatas = [];
82
76
83
- public function __construct (ContainerInterface $ container , FixturesLoaderFactory $ fixturesLoaderFactory )
77
+ public function __construct (ContainerInterface $ container , FixturesLoaderFactoryInterface $ fixturesLoaderFactory )
84
78
{
85
79
$ this ->container = $ container ;
86
80
$ this ->eventDispatcher = $ container ->get ('event_dispatcher ' );
@@ -106,7 +100,6 @@ public function setObjectManagerName(string $omName = null): void
106
100
{
107
101
$ this ->omName = $ omName ;
108
102
$ this ->om = $ this ->registry ->getManager ($ omName );
109
- $ this ->connection = $ this ->registry ->getConnection ($ omName );
110
103
}
111
104
112
105
public function setRegistryName (string $ registryName ): void
@@ -271,18 +264,5 @@ protected function getCacheMetadataParameter()
271
264
&& false !== $ this ->container ->getParameter (self ::CACHE_METADATA_PARAMETER_NAME );
272
265
}
273
266
274
- private function getPlatformName (): string
275
- {
276
- $ platform = $ this ->connection ->getDatabasePlatform ();
277
-
278
- if ($ platform instanceof AbstractMySQLPlatform) {
279
- return 'mysql ' ;
280
- } elseif ($ platform instanceof SqlitePlatform) {
281
- return 'sqlite ' ;
282
- } elseif ($ platform instanceof PostgreSQLPlatform) {
283
- return 'pgsql ' ;
284
- }
285
-
286
- return (new \ReflectionClass ($ platform ))->getShortName ();
287
- }
267
+ abstract protected function getPlatformName (): string ;
288
268
}
0 commit comments