|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Malef\Associate\DoctrineOrm\Loader; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
6
|
|
|
use Malef\Associate\DoctrineOrm\Collector\AssociationCollector; |
|
7
|
|
|
use Malef\Associate\DoctrineOrm\Loader\ArgumentConverter\AssociationsArgumentConverter; |
|
8
|
|
|
use Malef\Associate\DoctrineOrm\Loader\ArgumentConverter\EntitiesArgumentConverter; |
|
9
|
|
|
use Malef\Associate\DoctrineOrm\Metadata\MetadataAdapterProvider; |
|
10
|
|
|
|
|
11
|
|
|
class EntityLoaderFactory |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var AssociationLoader |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $associationLoader; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var AssociationCollector |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $associationCollector; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var UninitializedProxiesLoader |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $uninitializedProxiesLoader; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct( |
|
29
|
|
|
AssociationLoader $associationLoader, |
|
30
|
|
|
AssociationCollector $associationCollector, |
|
31
|
|
|
UninitializedProxiesLoader $uninitializedProxiesLoader |
|
32
|
|
|
) { |
|
33
|
|
|
$this->associationLoader = $associationLoader; |
|
34
|
|
|
$this->associationCollector = $associationCollector; |
|
35
|
|
|
$this->uninitializedProxiesLoader = $uninitializedProxiesLoader; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function create(EntityManagerInterface $entityManager): EntityLoader |
|
39
|
|
|
{ |
|
40
|
|
|
return new EntityLoader( |
|
41
|
|
|
new EntitiesArgumentConverter(), |
|
42
|
|
|
new AssociationsArgumentConverter(), |
|
43
|
|
|
new MetadataAdapterProvider($entityManager), |
|
44
|
|
|
$this->associationLoader, |
|
45
|
|
|
$this->associationCollector, |
|
46
|
|
|
$this->uninitializedProxiesLoader |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|