|
1
|
|
|
<?php |
|
2
|
|
|
/******************************************************************************* |
|
3
|
|
|
* This file is part of the GraphQL Bundle package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) YnloUltratech <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
******************************************************************************/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Test\FixtureLoader\DataPopulator; |
|
12
|
|
|
|
|
13
|
|
|
use Doctrine\Bundle\DoctrineBundle\Registry; |
|
14
|
|
|
use Doctrine\Common\DataFixtures\Executor\AbstractExecutor; |
|
15
|
|
|
use Doctrine\Common\DataFixtures\Executor\ORMExecutor; |
|
16
|
|
|
use Doctrine\Common\DataFixtures\Purger\ORMPurger; |
|
17
|
|
|
use Doctrine\DBAL\Connection; |
|
18
|
|
|
use Doctrine\DBAL\Driver; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class ORMDataLoader |
|
22
|
|
|
*/ |
|
23
|
|
|
class ORMDataLoader implements DataLoaderInterface |
|
24
|
|
|
{ |
|
25
|
|
|
protected $cacheDir; |
|
26
|
|
|
|
|
27
|
22 |
|
public function __construct($cacheDir = null) |
|
28
|
|
|
{ |
|
29
|
22 |
|
$this->cacheDir = $cacheDir; |
|
30
|
22 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* {@inheritdoc} |
|
34
|
|
|
*/ |
|
35
|
22 |
|
public function supports(Registry $registry): bool |
|
36
|
|
|
{ |
|
37
|
22 |
|
return $registry->getName() === 'ORM'; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
22 |
|
public function createExecutor(Registry $registry): AbstractExecutor |
|
44
|
|
|
{ |
|
45
|
22 |
|
$om = $registry->getManager(); |
|
46
|
22 |
|
$purger = new ORMPurger(); |
|
47
|
|
|
|
|
48
|
22 |
|
if (($connection = $registry->getConnection()) |
|
49
|
22 |
|
&& $connection instanceof Connection |
|
50
|
22 |
|
&& $connection->getDriver() instanceof Driver\AbstractSQLiteDriver) { |
|
51
|
22 |
|
return new SQLiteORMExecutor($om, $purger, $this->cacheDir); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return new ORMExecutor($om, $purger); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|